I have a list of csv files "name.csv" that I want to use to make various analyses in QGIS. I would like to automatize the following steps for each file :
- create new project name_main.qgis;
- import text layer;
- import polygon layer;
- [... some analyses...]
- save project to a new directory
I know it is possible to do batch analyses with the Atlas plugin, e.g. to export various maps. I also looked at the processing plugin but it seems to work only within one project. But in this case the different files correspond to different projects, not maps.
Each dataset corresponds to 1 site within 1 region. I would like to be able to visualize each map, if possible. Hence various projects. But to be more precise, I need to calculate mean slope from polygons (so, raster interpolation, terrain analysis and zonal statistics). I also need to reproject all the maps (coordinates x,y,z in meters) with GPS coordinates I have for 4 points each time.
Maybe I should first reproject from gps points and then merge all the sites in one map to do batch analyses?
I got the first steps to work but I have an issue for importing shapefiles: I need to first create shapefiles from text files, then to re-import the shapefile.
Here is what I have :
for cname in glob.glob('*.txt'): uri2 = "file:///" + csv_path + cname + "?delimiter=%s&wktField=%s" % (";", "wkt") name = cname.replace('.txt', '') cont = QgsVectorLayer(uri2, name, "delimitedtext") shlayer = QgsVectorFileWriter.writeAsVectorFormat(cont,csv_path + name +'.shp',"utf-8",None,"ESRI Shapefile") # Add to QGIS canvas iface.addVectorLayer(shlayer, name, "ogr")
The shlayer is not created, and obviously I get an error when I try to import it. Is there a problem with how I import the WKT layer ?