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.

Thanks.

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
1  
The simplest and computationally most efficient way in this particular example is to divide the values by 1000, take the ceiling, and cap the result at 10. Those three local arithmetic operations will be fast; you won't have to set up a reclassification table; and (because of that) there's no table where typographical entry errors will create subtle errors. But for a weighted overlay operation you would be better off not reclassifying the data at all... . –  whuber Jul 15 at 22:05
    
this question came up recently: gis.stackexchange.com/questions/116473/… –  user1269942 Oct 14 at 22:58

2 Answers 2

up vote 6 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:

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.

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

Try open source program GridMap Reclass at SourceForge: http://sourceforge.net/projects/mapgridreclass/

share|improve this answer
1  
Could you add some more information to your answer (maybe the information from SF) like if you've used it with a non-integral raster and had success? –  Paul Jul 15 at 17:53

Your Answer

 
discard

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.