Opened 21 years ago

Last modified 20 years ago

#436 closed defect (invalid)

min/max value shift in gdal_translate (BIL -> GeoTIFF)?

Reported by: Markus Neteler Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

Frank,

by chance I observed a strange vertical shift with SRTM 90m data
when converting from BIL to GeoTIFF:

#docs:
ftp://edcsgs9.cr.usgs.gov/pub/data/srtm/Documentation/Notes_for_ARCInfo_users.txt

#file source (SRTM/USGS):
ftp://edcsgs9.cr.usgs.gov/pub/data/srtm/Eurasia/N45E010.hgt.zip
unzip N45E010.hgt.zip

#renamed to a useful extension:
mv N45E010.hgt N45E010.bil

#created BIL header according to documentation (see above):
#Hope I got ULXMAP and ULYMAP right!
#
#ULXMAP = E + 0.0004166667
#ULYMAP = N + 1.0004166667
#
nedit N45E010.hdr
BYTEORDER     M
LAYOUT        BIL
NROWS         1201
NCOLS         1201
NBANDS        1
NBITS         16
BANDROWBYTES  2402
TOTALROWBYTES 2402
BANDGAPBYTES  0
NODATA        -32768
ULXMAP        10.0004166667
ULYMAP        46.0004166667
XDIM          0.000833333333333
YDIM          0.000833333333333

###############################################
#Test1:

gdalinfo -mm N45E010.bil
Driver: EHdr/ESRI .hdr Labelled
Size is 1201, 1201
Coordinate System is `'
Origin = (10.000000,46.000833)
Pixel Size = (0.000833,-0.000833)
Corner Coordinates:
Upper Left  (  10.0000000,  46.0008333)
Lower Left  (  10.0000000,  45.0000000)
Upper Right (  11.0008333,  46.0008333)
Lower Right (  11.0008333,  45.0000000)
Center      (  10.5004167,  45.5004167)
Band 1 Block=1201x1 Type=Int16, ColorInterp=Undefined
    Computed Min/Max=-3.000,2665.000
  NoData Value=-32768

#-> see Min/Max, maybe ok
# [coordinates look a bit shifted as well, but I tried to follow the
#  calculation suggested in the docs above]
#make BIL -> GeoTIFF
gdal_translate N45E010.bil N45E010.tif
Input file size is 1201, 1201
0...10...20...30...40...50...60...70...80...90...100 - done.

#Test2:
gdalinfo -mm N45E010.tif
Driver: GTiff/GeoTIFF
Size is 1201, 1201
Coordinate System is `'
Origin = (10.000000,46.000833)
Pixel Size = (0.000833,-0.000833)
Corner Coordinates:
Upper Left  (  10.0000000,  46.0008333)
Lower Left  (  10.0000000,  45.0000000)
Upper Right (  11.0008333,  46.0008333)
Lower Right (  11.0008333,  45.0000000)
Center      (  10.5004167,  45.5004167)
Band 1 Block=1201x3 Type=Int16, ColorInterp=Gray
    Computed Min/Max=-24.000,2652.000
  NoData Value=-32768

#-> see Min/Max, oops. Deviates from BIL min/max.

This looks unusual to me as we only perfomr a format change,
no warping.

Best regards

 Markus Neteler

Change History (1)

comment:1 by warmerdam, 20 years ago

Markus, 

I looked into this and it seems the differences are related to how the
image is sampled to compute the min/max values.  The BIL file is split into
scanline sized blocks while the output file has 3 scanlines per block.  Thus
the subsampling gets different data, and happens to miss/find different min/max
values. 

I did a careful inspection and it seems the actual output data was not different
than the input data. 

Note: See TracTickets for help on using tickets.