Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.


share|improve this question
for a weighted overlay, you can use r.series. Unfortunately only for grass7 you can specify the weight for each raster. If you have problems with the r.series open a new question. –  nickves Apr 10 '13 at 1:17
add comment

1 Answer

up vote 4 down vote accepted

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:



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.

share|improve this answer
Thanks. Worked like a charm. –  Fezter Apr 10 '13 at 4:38
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.