How do we load Rasters stored in PostGres-PostGIS or Oracle Spatial 11g into QGIS using PyQgis ?
I am able to load vector layers from Oracle 11g with below code.What changes are necessary to add Raster layers.The files are in tif format.
#Connect to Oracle and Fetch Table Names
con = cx_Oracle.connect('myoradb/myoradb@189.53.61.140:1521/newdev')
print con.version
cur = con.cursor()
cur.execute(u"select TABLE_NAME from user_tab_columns where data_type='SDO_GEOMETRY'")
tables = cur.fetchall()
uri = QgsDataSourceURI()
uri.setConnection("189.53.61.140", "1521", "newdev", "myoradb", "myoradb")
QgsProject.instance().writeEntry('WFSLayers', "/", [])
for t in tables :
print str(t[0])
uri.setDataSource('', str(t[0]), "GEOMETRY")
uri.uri()
vlayer = QgsVectorLayer(uri.uri(),str(t[0]), 'oracle')
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
lst = [ vlayer.id() ]
pWfsLayer.append(u'%s' % vlayer.id())
pLayers.append(u'%s' % vlayer.name())
pLayerIDs.append(vlayer.id())
render.setLayerSet(lst)
rect = QgsRectangle(render.fullExtent())
rect.scale(1.1)
render.setExtent(rect)
Aucun commentaire:
Enregistrer un commentaire