[gdal-dev] Scaling images with gdal_translate

Dillabough, Craig Craig.Dillabough at AGR.GC.CA
Fri Jun 19 13:44:58 EDT 2009


I am scaling a 32-bit floating point GeoTiff image, using the command:

gdal_translate -ot Byte -of GTiff -scale -a_nodata 0
Av.MaxNDVI.2000.2009.Week.19.tif overview/week19.8bpp.tif

My understanding is that the -scale option should scale my image from:

Min_value -> 0
Max_value -> 255

And everything in between is scaled linearly. 

After doing so, I run gdalinfo on the output week19.8bpp.tif which among
the other things it spits out is the following:

1  Driver: GTiff/GeoTIFF
2  Files: week19.8bpp.tif
3         week19.8bpp.tif.aux.xml
4  Size is 28800, 9600
5  Coordinate System is:
   ....
6  Origin = (-10007554.677000004798174,6671703.118001982569695)
7  Pixel Size = (231.656358263958310,-231.656358263958339)
8  Metadata:
9  AREA_OR_POINT=Area
10 TIFFTAG_SOFTWARE=IMAGINE TIFF Support
11 Copyright 1991 - 1999 by ERDAS, Inc. All Rights Reserved
12 @(#)$RCSfile: etif.c $ $Revision: 1.10.1.9.1.9.2.11 $ $Date:
2004/09/15 18:42:01EDT $
13   TIFFTAG_XRESOLUTION=1
14  TIFFTAG_YRESOLUTION=1
15   TIFFTAG_RESOLUTIONUNIT=1 (unitless)
16 Image Structure Metadata:
17  INTERLEAVE=BAND
18 Corner Coordinates:
19 Upper Left  (-10007554.677, 6671703.118) (180d 0'0.00"W, 60d
0'0.00"N)
......
20 Band 1 Block=28800x1 Type=Byte, ColorInterp=Gray
21  Min=-0.199 Max=563.324
22  Minimum=-0.199, Maximum=563.324, Mean=0.233, StdDev=0.228 
23  NoData Value=0
24  Metadata:
25    STATISTICS_MINIMUM=-0.19934794306755
.....
26    STATISTICS_HISTONUMBINS=65536
27    STATISTICS_HISTOMIN=-0.19934794306755
28    STATISTICS_HISTOMAX=563.32446289062
29    LAYER_TYPE=athematic
30
STATISTICS_HISTOBINVALUES=27|28|58|70|86|90|99|79|50|30|31|35|35|30|34|3
9|37|41|38|43|63|46|71|39553020|31    37620637|
32
12895729|6925105|5280415|4393664|3759686|3302997|2920409|2608889|2344772
|2069413|2216309|1720438|1361429|33    1252933|1197
34
673|1167295|1161275|1180804|1212838|1266437|1326368|1389520|1480545|1624
178|1825891|2039326|2224735|
35     2363030|2454439|2
36     515120|2547460|2570836|2604551|2652160|2697275|2738886|

And so on.

I had a few questions:
1. Am I correct that linear scaling is used (are there other options?)
2. I guess the Min and Max values (Line 21) are retained from the
original dataset, but I was sort of expecting to see a Min = 0 and Max =
255. Also, why is the 65000 bin histogram retained for a 8 bit image?  

It seems sort of confusing that some of the Tiff Tag data appears to be
updated while other stuff is just copied over from the original dataset.
Is there any way to force it to throw out/update the metadata?


Thanks for any information.
Craig




More information about the gdal-dev mailing list