[Qgis-user] QGIS layer to postgis database

xristosss20 saxri89 at gmail.com
Sun Sep 3 15:38:08 PDT 2017


I have two layers(layer1,layer2) in postgis database where I have connect in
QGIS project.
my database have specific precision.
now I want to use from QGIS processing some algorithms like
GISDIFFERENCE(for example I know tew postgis have query for this).
but I don't know how to import the algorithm output in postgis database
automatic to keep my database precision.
for example if I try to run graphical this tool show me choose to save as to
postgis database.
but how to do this using pyqgis ?because I want to create a QGIS plugin
some way is to run algorithms and I save manual the output to shapefile and
after to import this shapefile to postgis database like this :

outputs_QGISDIFFERENCE_1=processing.runalg('qgis:difference',
layer1,layer2,False,None)
load= QgsVectorLayer(outputs_QGISDIFFERENCE_1['OUTPUT'],'myname', 'ogr')
 QgsMapLayerRegistry.instance().addMapLayer(load)

and save to postgis database.
but that way create it me topology error because I loose the database
precision if I use the graphical way to save as to postgis database then
that layer is correct.
but how to do this using pyqgis ?



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html



More information about the Qgis-user mailing list