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)
asked Jul 22, 2019 at 16:06
1 Answer 1
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)
answered Jul 22, 2019 at 16:26
lang-py