# How to normalize elevation of GeoTIFF file data stored as unsigned integers?

I have a GeoTIFF file where the pixels are stored as unsigned 16 bit integers. I am using C# Gdal bindings to read the GeoTIFF file, using the Band.ReadRaster method, in order to produce an array of normalized values between 0 and 1.

I use ComputeRasterMinMax to compute the min and max value of all the data points in the band. For other GeoTiff files where pixels are stored as floats/doubles, it works out that the min and max are the absolute min and max elevation in meters. However, it is not clear to me if this is true when the pixels are stored as unsigned integers.

For instance, a sample file gives me 4000 as the min and 27000 as the max. If these are absolute elevations, then would I need to normalize each pixel via the method:

``````normalized pixel value = (pixel value - 4000) / 23000.
``````

Is that correct, or should I normalize the pixels using ushort.MinValue and ushort.MaxValue, i.e.:

``````normalized pixel value = (pixel value - ushort.MinValue) / (ushort.MaxValue - ushort.MinValue)
``````

which of course can be simplified given ushort.MinValue = 0.

• I think there's a typo shouldn't it be normalized pixel value = (pixel value - 4000) / 27000 (the text says 27000 but the calc is 2300)? Either way I would think the normalization equation should be more like (pixel value - raster_min) / (raster_max - raster_min). This would reduce the minimum to 0 and the maximum to 1 by reducing by the minimum then dividing by the difference between min and max which is a percentage as a decimal calculation. For the sake of speed I would set a new variable raster_diff = raster_max - raster_min then normalized = (pixel value - raster_min) / raster_diff. – Michael Stimson Nov 28 '19 at 5:17