Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is my code of python in qgis from qgis documentation docs

uri = QgsDataSourceURI()
uri.setConnection("localhost","5432","gis_data","postgres","vajja")
uri.setDataSource("","poi_sv1","long","","lat")
vlayer = QgsVectorLayer(uri.uri(),"LayerName","postgres")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)

Error:

  • NOTICE: WARNING: there is no transaction in progress

    Erroneous query: SELECT DISTINCT upper(geometrytype("long")),st_srid("long"),st_ndims("long") FROM "poidata"."poi_sv" returned 7 [ERROR: function geometrytype(double precision) does not exist LINE 1: SELECT DISTINCT upper(geometrytype("long")),st_srid("long"),..

    HINT: No function matches the given name and argument types. You might need to add explicit type casts.

    invalid PostgreSQL layer

My datatypes are in text and double precision. It tried both longitude and latitude in text and double precision but still it isn't working.
When I do debug I am getting error at vlayer line 4 from the above code

share|improve this question
1  
Please be aware that there is a code button {} that makes code formatting easy. As it stands you do not seem to be telling us what you are trying to do so I recommend using the edit button to try and make your question clearer by the inclusion of a question mark in its body. –  PolyGeo Aug 20 at 21:52
    
thanks for the info –  Vajja Raja Gopal Aug 20 at 22:01
    
Is your geometry column called "long"? –  Nathan W Aug 21 at 2:43
    
No it's double precision –  Vajja Raja Gopal Aug 21 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.