gdal reclassify

A few weeks ago I saw somebody was looking on gis.stackexchange for a command line tool to reclassify the ESA’s Globcover land cover dataset (  I often need to reclassify raster data, but in most cases I need to do it as a step in a larger python script, or I use the QGIS raster calculator. Inspired by the gis.stackexchange post, I decided a standalone tool might be handy for writing bash scripts.

Last weekend I posted the first version on github: It still needs more work – the only supported output format is .tif.  It’s also a wee bit slow.  Reclassifying a Landsat band is okay, taking only about 5-10 seconds on my laptop, but a really large raster like Globcover (300m pixel size for the globe = 129600 x 55800) takes just under 45 minutes (ugh!). The good news is that it can handle a file a large as Globcover.  It also gives you some control over the output datatype based on your output class values.  If your output classes are 8-bit unsigned, your output file will be 8-bit unsigned.  Likewise, if your output classes are 32-bit float, your output file will be 32-bit float – regardless of the datatype of your input raster.  Another useful feature is that the user can set a default value for pixels that do not meet any reclass conditions, and the default value can be set as the nodata value.


Leave a Reply

Your email address will not be published. Required fields are marked *