Skip to content

Commit

Permalink
Merge pull request #1718 from girder/geospatial-check
Browse files Browse the repository at this point in the history
Better detect files with geotransform data that aren't geospatial
  • Loading branch information
manthey authored Nov 5, 2024
2 parents 22eb9cf + 4dd780d commit 395d03a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Format dates in item lists ([#1707](../../pull/1707))
- Guard dtype types ([#1711](../../pull/1711), [#1714](../../pull/1714), [#1716](../../pull/1716))
- Better handle IndicaLabs tiff files ([#1717](../../pull/1717))
- Better detect files with geotransform data that aren't geospatial ([#1718](../../pull/1718))

### Changes

Expand Down
8 changes: 7 additions & 1 deletion sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,13 @@ def isGeospatial(path):
if ds.GetProjection():
return True
if ds.GetGeoTransform(can_return_null=True):
return True
w = ds.RasterXSize
h = ds.RasterYSize
trans = ds.GetGeoTransform(can_return_null=True)
cornersy = [trans[3] + x * trans[4] + y * trans[5]
for x, y in {(0, 0), (0, h), (w, 0), (w, h)}]
if min(cornersy) >= -90 and max(cornersy) <= 90:
return True
if ds.GetDriver().ShortName in {'NITF', 'netCDF'}:
return True
return False
Expand Down

0 comments on commit 395d03a

Please sign in to comment.