Friday 21 July 2017

Reclassifying rasters using GDAL and Python?


Using @SS_Rebelious very useful answer, I am trying to reclassify rasters using GDAL and Python.


I have a grayscale raster (with values ranging from 0 to 255) and I want to reclassify it to a binary raster.


From the answer I referenced, I'm using the following line:


# reclassify raster values equal 16 to 7 using Numpy
temp = numpy.equal(raster, 16)
numpy.putmask(raster, temp, 7)

I'm experimented with something like this:



temp = numpy.greater_equal(raster, 1)

This seems to work fine, but is this best way of reclassifying a raster using Python?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...