Monday 29 June 2015

Changing raster cell values within a polygon using QGIS GUI?


I would like to know how to change the values of raster cells which are within a polygon, leaving all cell values outside the polygon unchanged. I would like to subtract 1.5m from each raster cell value within the polygon, rather than make them all the same value.



I don't know how to use GRASS so I'm hoping there is a way to do it using the tools within the QGIS GUI, raster calculator, or processing toolbox. I'm using QGIS 2.0.


Thanks.



Answer



First, you need to convert your polygon to a raster. Create an integer field filled with "1" for the purpose of the conversion. (raster > conversion > rasterize)


Then, you can use the raster calculator to substract 1.5 where your polygon exists.


 yourdem@1 - ((poltoras@1 = 1) * 1.5 ) 

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