locationtech / geotrellis

GeoTrellis is a geographic data processing engine for high performance applications.
http://geotrellis.io
Other
1.33k stars 362 forks source link

Get wrong crs from tif file with coordinates ESRI:54009 #3489

Open imperio-wxm opened 1 year ago

imperio-wxm commented 1 year ago

Describe the bug

Crs info error when reading a tiff file with coordinates ESRI:54009

To Reproduce

image

cog.tiff.zip

 val path = "./cog.tiff"

val sourceRDD: RDD[RasterSource] = sc.parallelize(Seq(path)).map(uri => {
     GeoTiffRasterSource(uri): RasterSource
})

println(s"CRS = ${sourceRDD.first().crs}")

CRS = LatLng

When I debugged the TiffTags class, I found that there was a problem with the acquisition of crs, and the default LatLng coordinate system was used.

image

Environment

pomadchin commented 1 year ago

Hey @imperio-wxm, GT does not support ESRI projections, so it is not a bug; we default back to LatLng in this case, similar to GDAL.

cs.Tags.model contains 6.3.1.1 Model Type Codes.

6.3.1.1 Model Type Codes

Ranges:
   0              = undefined
   [   1,  32766] = GeoTIFF Reserved Codes
   32767          = user-defined
   [32768, 65535] = Private User Implementations
GeoTIFF defined CS Model Type Codes:
   ModelTypeProjected   = 1   /* Projection Coordinate System         */
   ModelTypeGeographic  = 2   /* Geographic latitude-longitude System */
   ModelTypeGeocentric  = 3   /* Geocentric (X,Y,Z) Coordinate System */

As you can can see, this code https://github.com/locationtech/geotrellis/blob/master/raster/src/main/scala/geotrellis/raster/io/geotiff/tags/TiffTags.scala#L339-L364 handles support of ModelTypeProjected and ModelTypeGeographic models only. 32767 matches to the user-defined model which is not handled at the moment (handled as None).

imperio-wxm commented 1 year ago

@pomadchin Hi, why doesn't it throw an unsupported exception? The default LatLng will cause crs and extent to not be in the same system, no errors will be reported during the calculation process, and it is difficult to find problems.

pomadchin commented 1 year ago

Well no error is because very often it happens so that the dataset contains invalid or a partially valid GIS data (it is pretty much imperfect and contains a lot of legacy usually).

Another argument is to align with the GDAL behavior.

I would agree though, at least some extra logging could help.