Sunday, 16 October 2016

qgis - Geoprocessing tool Difference from the Terminal?


I have used QGIS Geoprocessing tool Difference to cut polylines (SHP) into to smaller pieces using a polygon (SHP). This works very good in QGIS.


Now, to speed up the process, I'd like to be able to do the exact same thing but from the Terminal (so I can later make a shell script).


Maybe GDAL has these functions? In that case, how?


I'm using a Mac.



Answer



Maybe can you try ogr2ogr -clipdst DATASOURCE destinationFile sourceFile. For example : ogr2ogr-clipdst yourPolygon.shp destinationFile yourPolylines.shp.


But, in this case, you will cut one shapefile with another. If you want to cut your polylines shapefile with each features of a polygon shapefile, you must split the polygon shapefile and iterate over each polygon feature. For example: ogr2ogr -clipdst myFirstPolygonFeature destinationFile yourPolylines.shp.



Here is the man page: http://www.gdal.org/ogr2ogr.html.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...