[Qgis-developer] Load Oracle Spatial Raster using PyQGIS

ddurgaprasad dgplinux at yahoo.com
Tue Feb 3 18:21:53 PST 2015


I am able to connect to Oracle Spatial 11g and print tables with
SDO_GEORASTER attribute both in QGIS python console and standalone
application.I get below error when loading rasters from oracle Table.

*Traceback (most recent call last): File "", line 1, in Exception: unknown*


strProjetName =
"C:/OSGeo4W/apache/htdocs/QGIS-Web-Client-master/projects/myworld.qgs"
    def add_LayersFromDB():
        QGISAPP = QgsApplication(sys.argv, True)     
        QgsApplication.setPrefixPath(r"C:\OSGeo4W\apps\qgis", True)
        QgsApplication.initQgis()

        #Connect to Oracle and Fetch Table Names 
        con = cx_Oracle.connect('myoradb/myoradb at 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_GEORASTER'")

        tables = cur.fetchall()
        print tables

        QgsProject.instance().setFileName(strProjetName)
        print QgsProject.instance().fileName()
        render = QgsMapRenderer()

        uri = QgsDataSourceURI()
        uri.setConnection("189.53.61.140", "1521", "newdev", "myoradb",
"myoradb")

        render = QgsMapRenderer()

        for t in tables :
           print str(t[0])      
           uri.setDataSource('',  str(t[0]), "RAST")
           uri.uri()
           vlayer = QgsRasterLayer(uri.uri(),str(t[0]), 'oracle') #FAILS
HERE
           QgsMapLayerRegistry.instance().addMapLayer(vlayer)
           lst = [ vlayer.id() ]
           render.setLayerSet(lst)
           rect = QgsRectangle(render.fullExtent())            
           rect.scale(1.1)
           render.setExtent(rect)

        QgsProject.instance().write()
        cur.close()
        con.close()         
        QgsApplication.exitQgis()

    add_LayersFromDB()



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Load-Oracle-Spatial-Raster-using-PyQGIS-tp5185365.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list