Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdalinfo incorrectly identifies BIL tiles as having many bands (thousands to millions) #1961

Closed
open-src-is-great opened this issue Oct 28, 2019 · 2 comments

Comments

@open-src-is-great
Copy link

BACKGROUND
I'm building a global elevation dataset consisting of BIL files generated from source GeoTIF files. This task is accomplished by way of a custom tool that walks a grid of the Earth, each cell being 150x150 pixels, and invokes gdalwarp to operate on each cell region. Using gdalinfo to query the generated BILs, I receive "Invalid band count" on a small percentage of BIL files. These should contain exactly one band (elevation values), but the error identifies band count from thousands to millions, depending upon the specified BIL. Manually sampling parts of the BIL file yielded the values that I expected, so the data itself appears correct.

REPRODUCE
One such case occurs after running the following gdalwarp command against the attached GeoTIF file to generate a BIL of a specified sub-region.

-> gdalwarp -overwrite -q -of ENVI -r bilinear -co INTERLEAVE=BIL -multi -te 68.74580536912751 24.995805369127517 70.00419463087249 26.254194630872483 -dstnodata -9999.0 -ot Int16 -ts 150 150 23N068E_20101117_gmted.tif output.bil
-> gdalinfo output.bil ERROR 1: Invalid band count : 2621482. Maximum allowed currently is 65536. Define GDAL_MAX_BAND_COUNT to a higher level if it is a legitimate number. gdalinfo failed - unable to open 'output.bil'.

WORKAROUND
Doing any of the following works around the problem in most cases, with gdalinfo successfully printing the correct metrics for output.bil:

  1. Setting GDAL_MAX_BAND_COUNT to well above the reported invalid band count, as suggested in the reported error.
  2. Re-run gdalwarp with Int32 in place of Int16 for -ot parameter (both source and target tiles are Int16, so not sure why this helps).
  3. Re-run gdalwarp with a slight change to the extent (ex: change 2nd decimal place of xMax (26.254194630872483) from 5 to 6).

ENVIRONMENT
GDAL 2.3.2 built on RHEL7 (x64).

23N068E_20101117_gmted.tif.zip

rouault added a commit that referenced this issue Oct 28, 2019
…entification of raw binary formats such as ENVI (fixes #1961)
rouault added a commit that referenced this issue Oct 28, 2019
…entification of raw binary formats such as ENVI (fixes #1961)
@rouault
Copy link
Member

rouault commented Oct 28, 2019

I've committed a fix. You can workaround this by defining the GDAL_SKIP=IRIS environment variable

@rouault rouault closed this as completed Oct 28, 2019
rouault added a commit that referenced this issue Oct 28, 2019
…entification of raw binary formats such as ENVI (fixes #1961)
@open-src-is-great
Copy link
Author

Excellent, thank you! Your workaround works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants