[GIS] Reclassifying float raster using QGIS

gmegrassqgisrasterreclassify

I have three rasters which represent distance (in metres) from certain things (bus stops, parks, libraries). I would like to reclassify these rasters so that they get integer values based on the following criteria:

between 1 - 1000 = 1
between 1000 - 2000 = 2
between 2000 - 3000 = 3
between 3000 - 4000 = 4
between 4000 - 5000 = 5
between 5000 - 6000 = 6
between 6000 - 7000 = 7
between 7000 - 8000 = 8
between 8000 - 9000 = 9
9000 and above = 10

I know how to do this in Spatial Analyst, but I don't have a license and I'm trying to use Open Source tools. I've attempted to use r.reclass and followed the tips in this question, but the input raster needs to be an integer raster. At the moment, my distance rasters are floats.

I've also tried using the reclassify tool in the Geospatial Modelling Environment but the input raster also needs to be an integer raster.

I've also tried using the Raster Calculator in QGIS by following this example, but it appears that that only works with a single criteria not 10.

I've been pulling my hair out trying to convert the rasters to integer, but can't figure it out.

Does anyone know how to either reclassify a float raster or convert a float raster to an integer raster?

Note, the end goal of this will be to perform a weighted overlay. Eventually, I may have Spatial Analyst in ArcGIS to do this, but I'd like to know how to do it using Open Source tools.

Best Answer

yes, r.reclass is for reclassing thematic rasters, like the Corine Land Cover. It will work for your data, but the routine will cast the float numbers to integers before doing the reclass, so it might lead to unexpected results.

What you are looking for is r.recode

The rules are defined in many formats, one of those is the following:

old_low:old_high:new_val (i.e. new_high == new_low)

So, based on your question the rules should be something along this lines:

rules.txt

1:1000:1
1000:2000:2
2000:3000:3
3000:4000:4
4000:5000:5
5000:6000:6
6000:7000:7
7000:8000:8
8000:9000:9
9000:*:10

So the command should be like this:

r.recode input=oldmap output=newmap rules="/path/to/rules.txt"

Afterwards you can use the r.reclass module for the newmap you created.

Related Question