QGIS : Create a vector layer from a GeoAlchemy2 query

66 views
Skip to first unread message

Marc Martinot

unread,
Jul 18, 2014, 11:10:53 AM7/18/14
to geoal...@googlegroups.com

Hello !

I don't know if I came to the right place but I thought that maybe I can get an answer here...

I'm currently developing a QGIS plugin where I mapped a PostGIS database via GeoAlchemy2.

I wrote a function that returns results from a GeoAlchemy query but have no idea how to create a vector layer from this (by using, for example, a function from QGIS API, like QgsVectorLayer(...)) and display it.

Is there any way to do this ? 

Thanks a lot,

Marc

vitor.f...@homeday.de

unread,
Oct 22, 2017, 12:07:41 PM10/22/17
to GeoAlchemy
Hey!

Did you figure this out?
I need to query with GeoAlchemy, transform the result into a QgsVectorLayer so I will be able to run QGIS analysis.

Thanks

vitor.f...@homeday.de

unread,
Oct 23, 2017, 3:40:37 AM10/23/17
to GeoAlchemy
Nevermind... 
I'm just using PyQGIS all the way like:

uri = QgsDataSourceURI()
uri.setConnection("localhost", "5432", "geo", "geo", "")
uri.setDataSource("public", "table", "shape_utm", "filter=12")
blocks_layer = QgsVectorLayer(uri.uri(False), "table", "postgres")
Reply all
Reply to author
Forward
0 new messages