2

I'm new to PyQGIS and trying to save the output of the processing tool 'create points layer from table'. I just need to save it as a shapefile. My code is below which seems to be functioning so far. Using QGIS v3.4.

params = { 'INPUT' : 'C:/Users/xxx/WeeklyContacts-2019-07-15.csv', 'MFIELD' : None, 'OUTPUT' : 'memory:', 'TARGET_CRS' : QgsCoordinateReferenceSystem('EPSG:27700'), 'XFIELD' : 'Easting', 'YFIELD' : 'Northing', 'ZFIELD' : None }
processing.run("qgis:createpointslayerfromtable", params)
4

Your 'OUTPUT' parameter is 'memory:'. That means once the processing finishes, you will get a temporary memory layer. Change it to a shapefile and a shapefile will be saved to the disk.

params = { 'INPUT' : 'C:/Users/xxx/WeeklyContacts-2019-07-15.csv', 'MFIELD' : None, 'OUTPUT' : 'C:/Users/xxx/WeeklyContacts-2019-07-15.shp', 'TARGET_CRS' : QgsCoordinateReferenceSystem('EPSG:27700'), 'XFIELD' : 'Easting', 'YFIELD' : 'Northing', 'ZFIELD' : None }
processing.run("qgis:createpointslayerfromtable", params)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.