Skip to content
command line tool to reclassify rasters
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



A command-line tool to reclassify raster data using GDAL.


  • python
  • numpy
  • gdal binaries
  • python-gdal bindings

Usage [-c source_classes] [-r dest_classes] [-d default] [-n default_as_nodata] src_dataset dst_dataset


Input classes as a comma-delimited string of value conditions that are to be reclassified.


Output classes as a comma-delimited string of values. The number of input classes must match the number of result values. The order of the output classes must match the order of the input classes. The output data type will match the datatype of the output classes.


Default value. Value used to fill pixels that do not meet any conditions of the input classes. If no default value is specified, the default will be 0.


No data. Setting to "true" sets the default value as the nodata value. If not set to "true" GDAL will determine the nodata value based on the ouput data type.


GDAL compression method. Examples:'COMPRESS=LZW','COMPRESS=PACKBITS','COMPRESS=DEFLATE' or 'COMPRESS=JPEG'. By default gdal_reclassfiy uses no compression. More information on compression can be found here:


The source file name.


The destination tiff file name.


    python source_dataset.tif destination_dataset.tif -c "<30, <50, <80, ==130, <210"
    -r "1, 2, 3, 4, 5" -d 0 -n true -p "COMPRESS=LZW"


Input classes are processed using This means that in many cases, consecutive ranges should be defined using "<" rather than ">" to avoid classes over-riding each other. For example "> 0, > 2, > 4" will produce one class that is greater than 4 trumping the first two conditions, whereas "< 3, < 5, < 10" will produce 3 classes.

Later versions will ouput different raster formats, but currently outputs must have the .tif extension.

Thanks to Chris Garrard for providing such great Python GDAL tutorials:

You can’t perform that action at this time.