Tuesday 19 February 2019

qgis - Clipping raster with multiple polygons and naming the resulting rasters


I am trying to split a single-band raster (land cover) into smaller parts representing administrative units which are into another shapefile, containing their name as an attribute.


U I did this using SAGA "clip raster with polygon" (in QGIS 2.18) to split the raster and then naming the resulting rasters one by one (by hand) with the name of the administrative unit.



enter image description here


The problem is, I now need to do this process over ±2000 polygons, so doing it by hand is the last resort options.


I tried different options:
a) Using SAGA "clip raster with polygon", iterate over the polygon layer. Works good, but cannot specify an attribute to use a name.


b) Batch-process SAGA "clip raster with polygon" using individual administrative polygons, named after their administrative ID. Works fine, the name of the resulting rasters is as I want it, but the process is long and boring (batch-processing with 2000 rows, filled in part by hand, see image).


enter image description here


So, is there a way of speeding up the process? Is it possible to iterate over a layer, specifying an attribute to use as a name for the resulting layers? Is it possible to auto-fill the batch-processing window with layers open in the "layers panel"?




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...