[Gdal-dev] gdalwarp and nodata values (float v int)

Bryan Keith bryan at geomega.com
Fri Jul 14 13:39:19 EDT 2006


Hello again,

In the last couple days I've posted some messages regarding the AAIGrid 
driver reading integers v. floats.  That problem's not quite resolved, 
but I've done a little testing and found the following peculiarity with 
how gdalwarp handles nodata values.

I probably noticed the AAIGrid driver problem because I was using an 
integer for my nodata value in a floating point grid.  So I decided to 
test it using a floating point value (which I still haven't done yet). 
However, I get unexpected results with gdalwarp and non-integer nodata 
values.

Consider the following examples.  I start with test.tif 
(Min/Max=1508.000,3413.000) and use gdalwarp 3 different times with only 
changing the -dstnodata value.  The first time I use -dstnodata 
-3.40282e+038 (the same as my -srcnodata) and end up with 
Min/Max=-340282001837565600000000000000000000000.000,3385.788  Then I 
use -dstnodata -99999 and get the expected Min/Max=1523.000,3385.788 
Then I use -dstnodata -99999.1 and get Min/Max=-99999.102,3385.788

What's going on here?

Bryan

 >gdalinfo test.tif -mm
Driver: GTiff/GeoTIFF
Size is 1201, 1201
Coordinate System is:
Origin = (-116.000417,41.000417)
Pixel Size = (0.00083333,-0.00083333)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (-116.0004167,  41.0004167) (116d 0'1.50"W, 41d 0'1.50"N)
Lower Left  (-116.0004167,  39.9995833) (116d 0'1.50"W, 39d59'58.50"N)
Upper Right (-114.9995833,  41.0004167) (114d59'58.50"W, 41d 0'1.50"N)
Lower Right (-114.9995833,  39.9995833) (114d59'58.50"W, 39d59'58.50"N)
Center      (-115.5000000,  40.5000000) (115d30'0.00"W, 40d30'0.00"N)
Band 1 Block=1201x1 Type=Float32, ColorInterp=Gray
     Computed Min/Max=1508.000,3413.000
   NoData Value=-3.40282e+038

 >gdalwarp -s_srs EPSG:4322 -t_srs EPSG:32008 -tr 1640 1640 -te 683628 
1911258.125 968988.0 2280258.125 -rb -srcnodata -3.40282e+038 -dstnodata 
-3.40282e+038 test.tif testw.tif
Creating output file that is 174P x 225L.
Processing input file test.tif.
:0...10...20...30...40...50...60...70...80...90...100 - done.
Open GDAL Datasets:
   1 N DriverIsNULL 512x512x0

 >gdalinfo testw.tif -mm
Driver: GTiff/GeoTIFF
Size is 174, 225
Coordinate System is:
Origin = (683628.000000,2280258.125000)
Pixel Size = (1640.00000000,-1640.00000000)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (  683628.000, 2280258.125) (116d 0'4.59"W, 41d 0'38.27"N)
Lower Left  (  683628.000, 1911258.125) (116d 0'40.36"W, 39d59'51.82"N)
Upper Right (  968988.000, 2280258.125) (114d58'3.19"W, 41d 0'0.09"N)
Lower Right (  968988.000, 1911258.125) (114d59'34.47"W, 39d59'14.98"N)
Center      (  826308.000, 2095758.125) (115d29'35.81"W, 40d30'0.47"N)
Band 1 Block=174x11 Type=Float32, ColorInterp=Gray
     Computed Min/Max=-340282001837565600000000000000000000000.000,3385.788
   NoData Value=-3.40282e+038

 >gdalwarp -s_srs EPSG:4322 -t_srs EPSG:32008 -tr 1640 1640 -te 683628 
1911258.125 968988.0 2280258.125 -rb -srcnodata -3.40282e+038 -dstnodata 
-99999 test.tif testw.tif
Creating output file that is 174P x 225L.
Processing input file test.tif.
:0...10...20...30...40...50...60...70...80...90...100 - done.
Open GDAL Datasets:
   1 N DriverIsNULL 512x512x0

 >gdalinfo testw.tif -mm
Driver: GTiff/GeoTIFF
Size is 174, 225
Coordinate System is:
Origin = (683628.000000,2280258.125000)
Pixel Size = (1640.00000000,-1640.00000000)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (  683628.000, 2280258.125) (116d 0'4.59"W, 41d 0'38.27"N)
Lower Left  (  683628.000, 1911258.125) (116d 0'40.36"W, 39d59'51.82"N)
Upper Right (  968988.000, 2280258.125) (114d58'3.19"W, 41d 0'0.09"N)
Lower Right (  968988.000, 1911258.125) (114d59'34.47"W, 39d59'14.98"N)
Center      (  826308.000, 2095758.125) (115d29'35.81"W, 40d30'0.47"N)
Band 1 Block=174x11 Type=Float32, ColorInterp=Gray
     Computed Min/Max=1523.000,3385.788
   NoData Value=-99999

 >gdalwarp -s_srs EPSG:4322 -t_srs EPSG:32008 -tr 1640 1640 -te 683628 
1911258.125 968988.0 2280258.125 -rb -srcnodata -3.40282e+038 -dstnodata 
-99999.1 test.tif testw.tif
Creating output file that is 174P x 225L.
Processing input file test.tif.
:0...10...20...30...40...50...60...70...80...90...100 - done.
Open GDAL Datasets:
   1 N DriverIsNULL 512x512x0

 >gdalinfo testw.tif -mm
Driver: GTiff/GeoTIFF
Size is 174, 225
Coordinate System is:
Origin = (683628.000000,2280258.125000)
Pixel Size = (1640.00000000,-1640.00000000)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (  683628.000, 2280258.125) (116d 0'4.59"W, 41d 0'38.27"N)
Lower Left  (  683628.000, 1911258.125) (116d 0'40.36"W, 39d59'51.82"N)
Upper Right (  968988.000, 2280258.125) (114d58'3.19"W, 41d 0'0.09"N)
Lower Right (  968988.000, 1911258.125) (114d59'34.47"W, 39d59'14.98"N)
Center      (  826308.000, 2095758.125) (115d29'35.81"W, 40d30'0.47"N)
Band 1 Block=174x11 Type=Float32, ColorInterp=Gray
     Computed Min/Max=-99999.102,3385.788
   NoData Value=-99999.1

Bryan Keith
GIS Specialist
Geomega, Inc.
Boulder, CO, USA



More information about the Gdal-dev mailing list