Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5892 closed defect (fixed)

Krovak projection not properly stored by GTiff

Reported by: Mike Taves Owned by: warmerdam
Priority: low Milestone: 2.0.0
Component: default Version: 1.11.1
Severity: normal Keywords:
Cc:

Description (last modified by Mike Taves)

The GTiff driver does not properly store Krovak projections, namely EPSG codes 2065, 5221, 5513 and 5514. While the EPSG codes can be imported by OSR, and exported to PROJ.4 and WKT outputs, the data is lost when written to GeoTIFF.

from osgeo import osr, gdal
osr.UseExceptions()
gdal.UseExceptions()
drv = gdal.GetDriverByName('GTiff')
for code in [2065, 5221, 5513, 5514]:
    print('EPSG:' + str(code))
    fname = '/vsimem/tmp' + str(code)
    srs = osr.SpatialReference()
    srs.ImportFromEPSG(code)
    print('Input PROJ.4: ' + srs.ExportToProj4())
    ds = drv.Create(fname, 2, 3)
    ds.SetProjection(srs.ExportToWkt())
    ds = None
    ds = gdal.Open(fname)
    wkt_out = ds.GetProjection()
    ds = None
    gdal.Unlink(fname)
    srs_out = osr.SpatialReference()
    srs_out.ImportFromWkt(wkt_out)
    print('Output PROJ.4: ' + srs_out.ExportToProj4())

shows

EPSG:2065
Input PROJ.4: +proj=krovak +lat_0=49.5 +lon_0=42.5 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +pm=ferro +units=m +no_defs 
Output PROJ.4: 
EPSG:5221
Input PROJ.4: +proj=krovak +lat_0=49.5 +lon_0=42.5 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +pm=ferro +units=m +no_defs 
Output PROJ.4: 
EPSG:5513
Input PROJ.4: +proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +units=m +no_defs 
Output PROJ.4: 
EPSG:5514
Input PROJ.4: +proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +units=m +no_defs 
Output PROJ.4: 

Note the none of these have an output PROJ.4, just an empty string. Further note that the first line of WKT is "LOCAL_CS["S-JTSK (Ferro) / Krovak",", rather than PROJCS["S-JTSK (Ferro) / Krovak", from the input srs.

Change History (4)

comment:1 by Mike Taves, 9 years ago

Description: modified (diff)

comment:2 by Even Rouault, 9 years ago

There's no way to represent an arbitrary Krovak SRS in GeoTIFF spec currently. Although the geotiff driver could just looks at the PCS code when it's a SRS based on EPSG

comment:3 by Even Rouault, 9 years ago

Milestone: 2.0
Resolution: fixed
Status: newclosed

Fixed by #5926 trunk r28920 "GTiff: use importFromEPSG() when ProjectedCSTypeGeoKey is available (#5926)"

Note: will only work for Krovak projections as EPSG codes.

comment:4 by Even Rouault, 9 years ago

Milestone: 2.02.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.