Opened 19 years ago

Closed 13 years ago

#784 closed defect (fixed)

OGRCoordinateTransformation doesn't transform exotic datums without a TOWGS84 node

Reported by: ge@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SRS Version: unspecified
Severity: normal Keywords:
Cc:

Description (last modified by Even Rouault)

If you call OGRCreateCoordinateTransformation with a SRS whose GEOGCS node
doesn't include a TOWGS84 node, no datum transformation will happen unless the
datum is one of WGS84, NAD83, NAD27, NZGD43 or Potsdam.

Example:

from osr import *

srcSrs = SpatialReference()
srcSrs.ImportFromEPSG(4326) # WGS84
dstSrs = SpatialReference()
dstSrs.ImportFromWkt("""
    GEOGCS["WGS 72BE",
        DATUM["WGS_1972_Transit_Broadcast_Ephemeris",
            SPHEROID["WGS 72",6378135,298.26,AUTHORITY["EPSG","7043"]],
            AUTHORITY["EPSG","6324"]],
        PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4324"]]""")
print dstSrs.ExportToProj4()
ct = CoordinateTransformation(srcSrs, dstSrs)
print ct.TransformPoint(0, 0, 0)

The output:
+proj=longlat +ellps=WGS72 +no_defs 
(0.0, 0.0, 2.0)

No datum transformation had happened because there is no TOWGS84 node in dstSrs,
which in order caused OGRSpatialReference::exportToProj4 to emit no +towgs84 param.

I noticed this because the GetProjectionRef method of a GeoTiff GDALDataset
returns a WKT without a TOWGS84 node.  Should that be fixed instead/too?

As far as I understand the OGC specs, the TOWGS84 node is optional, so I'll
attach a patch that looks it up from gcs.csv

Attachments (1)

towgs84_from_epsg.diff (1.9 KB ) - added by ge@… 19 years ago.
Lookup the +towgs84 parameters in OGRSpatialReference::exportToProj4 from gcs.csv if there is no TOWGS84 node

Download all attachments as: .zip

Change History (3)

by ge@…, 19 years ago

Attachment: towgs84_from_epsg.diff added

Lookup the +towgs84 parameters in OGRSpatialReference::exportToProj4 from gcs.csv if there is no TOWGS84 node

comment:1 by warmerdam, 19 years ago

Gabriel, 

I have applied your patch.  Very nicely done.  I normally "fixup"
patches to match my conventions but yours fit in perfectly.

I am slightly concerned about the PROJ.4 translation adding the TOWGS84
parameters but after some consideration it does seem appropriate when 
I have the GEOGCS EPSG code. 

I will review the GeoTIFF driver situation.  

Best regards,

comment:2 by Even Rouault, 13 years ago

Description: modified (diff)
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.