[Gdal-dev] custom reclass/remap using gdal_translate

Gregory, Matthew matt.gregory at oregonstate.edu
Tue Feb 20 14:07:08 EST 2007


I did a *brief* review of the mailing lists and didn't see this question
addressed, although I'm sure someone has come up with a good solution.

I'm trying to create standard 8-bit unsigned geotiffs from a variety of
source data types (signed/unsigned ints, floats, etc.).  I would like
the output range on all images to look like:

0: No data
1-255: Scaled minimum/maximum of my projwin

Sample input includes (clipped from gdalinfo):

Driver: AIG/Arc/Info Binary Grid
Size is 11667, 9402
Band 1 Block=256x4 Type=Int16, ColorInterp=Undefined
  Minimum=148.000, Maximum=2887.000, Mean=1060.775, StdDev=452.013
  NoData Value=-32768

Driver: AIG/Arc/Info Binary Grid
Size is 11667, 9402
Band 1 Block=256x4 Type=Byte, ColorInterp=Undefined
  Minimum=0.000, Maximum=254.000, Mean=168.005, StdDev=43.652
  NoData Value=255

I have two questions:

1) Is there a standard algorithm for determining the min/max of a window
within an image.  I assume that you could get there by iterating over
the tiles that make up that window, but I didn't know if there was a
more elegant way that I was overlooking.

2) Is there functionality to provide a kind of "remap" table for
assigning src values to dst values?  For example, in the second image
provided above I would want to scale the range of the input values 0:254
to output values 1:255 and then convert input value 255 to output value
0.  Unless I'm overlooking something very obvious in gdal_translate,
this isn't straightforward because giving the options "-scale 0 254 1
255 -a_nodata 255" would first scale the data as desired but would then
turn the original 254s into No Data and the No Data value would still be
255.

Matt Gregory
Faculty Research Assistant
Department of Forest Science
Oregon State University
Phone : (541) 758-7778
Email : matt.gregory at oregonstate.edu




More information about the Gdal-dev mailing list