Skip to content

Commit

Permalink
Better detect files with geotransform data that aren't geospatial
Browse files Browse the repository at this point in the history
gdalwarp and gdal_translate can be used to transform images in pixel
space.  If such an image has no projection specified and cannot be
interpreted as latitude and longitude, assume it is not geospatial.
  • Loading branch information
manthey committed Nov 5, 2024
1 parent 22eb9cf commit 4dd780d
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 4dd780d

Please sign in to comment.