GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
306 stars 58 forks source link

UTM projection interpreted as 4326 #85

Closed cmalzer closed 3 years ago

cmalzer commented 3 years ago

First of all, thank you for your awesome work! I'm currently implementing my own application based on geotiff.io, with additional support for shapefiles and integration of Dataverse to search and map geospatial files.

Unfortunately, I have some GeoTiffs which are not getting displayed (not just in my own implementation, but also when uploading them on geotiff.io). I'm not getting any errors; but the debug info says: "georaster projection is in 4326" which is not the case since these files are actually in UTM48S /EPSG 32748. So I guess the problem is that they are incorrectly interpreted as having 4326 coordinate system.

This is the gdalinfo of one of these GeoTiffs:

Driver: GTiff/GeoTIFF
Files: DTM_PTPN6_UTM48S_EPSG_32748.tif
Size is 3487, 6349
Coordinate System is:
PROJCRS["WGS_1984_UTM_Zone_48S",
    BASEGEOGCRS["WGS 84",
        DATUM["World Geodetic System 1984",
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4326]],
    CONVERSION["Transverse Mercator",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",105,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",10000000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["easting",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    ID["EPSG",32748]]
Data axis to CRS axis mapping: 1,2
Origin = (320149.000000000000000,9815765.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  320149.000, 9815765.000) (103d22'59.74"E,  1d39'58.17"S)
Lower Left  (  320149.000, 9809416.000) (103d22'59.57"E,  1d43'24.88"S)
Upper Right (  323636.000, 9815765.000) (103d24'52.56"E,  1d39'58.27"S)
Lower Right (  323636.000, 9809416.000) (103d24'52.39"E,  1d43'24.97"S)
Center      (  321892.500, 9812590.500) (103d23'56.06"E,  1d41'41.57"S)
Band 1 Block=128x128 Type=Float32, ColorInterp=Gray
  Min=40.240 Max=89.060 
  Minimum=40.240, Maximum=89.060, Mean=65.718, StdDev=7.862
  NoData Value=-3.4028234663852886e+38
  Metadata:
    RepresentationType=ATHEMATIC
    STATISTICS_MAXIMUM=89.059997558594
    STATISTICS_MEAN=65.717556587957
    STATISTICS_MINIMUM=40.240001678467
    STATISTICS_SKIPFACTORX=1
    STATISTICS_SKIPFACTORY=1
    STATISTICS_STDDEV=7.8615856250965

I'm able to view the files after transforming them to 4326, but is there any way of fixing this without the need of transforming them?

Thank you!

DanielJDufour commented 3 years ago

Hey. Thanks for reaching out. Happy to help solve this issue. geotiff.io is using an older version of georaster-layer-for-leaflet. Do you have the same issue when you load the GeoTIFF here: https://geotiff.github.io/georaster-layer-for-leaflet-example/examples/load-file.html ?

cmalzer commented 3 years ago

Hi, thanks for your fast response! Yes, unfortunately the same is happening when I'm using this link. In the console at georaster --> projection it says "4326" and the map is empty. Only after converting it to WGS84 with gdalwarp I can see the file. Unfortunately I'm not allowed to share the file in public, but I could email it to you if this helps.

DanielJDufour commented 3 years ago

Okay. Thanks for trying though. You can email it to me at daniel.j.dufour@gmail.com and I can take a look.

DanielJDufour commented 3 years ago

I figured out the issue. It's this line in georaster: https://github.com/GeoTIFF/georaster/blob/master/src/parseData.js#L93

Basically, it currently mistakenly gives priority to GeographicTypeGeoKey vs. ProjectedCSTypeGeoKey, but it should be the reverse.

Sorry about that. I'll fix georaster and let you know when I've republished. Should be today or tomorrow. (There's a rather lengthly release process)

DanielJDufour commented 3 years ago

I published a new version of georaster. Should be working now!

cmalzer commented 3 years ago

Great, thanks a lot! It is now working when using the link above.

Could you possibly also update the geoblaze package? I'm using geoblaze as a wrapper in my application and I guess it is using the older georaster version which is why it is not yet working there. But I'm closing the issue here since it is definitely working with georaster now.

DanielJDufour commented 3 years ago

Okay. I published a new version of GeoBlaze! https://github.com/GeoTIFF/geoblaze/releases/tag/v1.0.3