[gdal-dev] Still Confused about datum transformations

dev4cx4m9z at snkmail.com dev4cx4m9z at snkmail.com
Sat Oct 22 01:47:43 EDT 2011


I have received many useful suggestions, but I am still struggling with what
should be a simple problem. I am trying to translate a series of lat/lon
coordinates in WGS84 coordinates to lat/lon coordinates for my map (AGD66).
The code is below, and seems to mirror sample code in the GDAL tutorials.
When I create the coordinate transform, I get error message "No PROJ.4
translation for source SRS, coordinate transformation initialization
failed".

 

PROJ.dll is in the right place, and GDAL_DATA and PROJ_LIB are correctly
defined. I don't think the error is here because when I put illegal
parameters (e.g. EPSG:111111) it throws an exception.

 

I have noticed that when I add a projection to the SRS it seems to help, but
I'm not up to that yet. All I want to do is transform from one datum to
another (in code). Can anyone see the simple mistake I must be making?

 

 

       Dim WGS84SRS As New OGRSpatialReference     ' Coordinate system in
WGS84

        Dim MapSRS As New OGRSpatialReference       ' Coordinate system of
map

        Dim ctWGS84toMap As New OGRCoordinateTransformation       '
Coordinate transform from WGS84 to map

        Dim WGS84WKT As String, MapWKT As String

        With WGS84SRS

            GDALError = .SetProjCS("WGS84 Datum")

            Debug.Assert(GDALError = OGRError.OGRERR_NONE,
GetLastErrorMsg())

            GDALError = .SetWellKnownGeogCS("WGS84")          ' Define WGS84
coordinate system

            Debug.Assert(GDALError = OGRError.OGRERR_NONE,
GetLastErrorMsg())

            WGS84WKT = .ExportToWkt

        End With

        With MapSRS

            GDALError = .SetProjCS("Map Datum")

            Debug.Assert(GDALError = OGRError.OGRERR_NONE,
GetLastErrorMsg())

            GDALError = .SetWellKnownGeogCS("EPSG:4202")          '
Australian Geodetic 1966

            Debug.Assert(GDALError = OGRError.OGRERR_NONE,
GetLastErrorMsg())

            MapWKT = .ExportToWkt

        End With

        ctWGS84toMap = GDAL.CreateCoordinateTransformation(WGS84SRS, MapSRS)
' Create a coordinate transformation - WGS84 to map

 

WGS84WKT = "PROJCS["WGS84 Datum",GEOGCS["WGS
84",DATUM["WGS_1984",SPHEROID["WGS
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],A
UTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],

UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG",
"4326"]]]"

 

MapWKT = "PROJCS["Map
Datum",GEOGCS["AGD66",DATUM["Australian_Geodetic_Datum_1966",SPHEROID["Austr
alian National
Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-117.808,-51.536,
137.784,0.303,0.446,0.234,-0.29],AUTHORITY["EPSG","6202"]],PRIMEM["Greenwich
",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EP
SG","9122"]],AUTHORITY["EPSG","4202"]]]"

 

_______________________________________

Marc Hillman, Melbourne, Australia

http://users.tpg.com.au/users/mhillman/

marc .hillman @ t p g . c o m . a u

Eagles may soar, but weasels don't get sucked into jet engines.

Early bird gets the worm, but the second mouse gets the cheese.

If Barbie is so popular, why do you have to buy her friends?

All those who believe in psychokinesis, raise my hand.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111022/af281b15/attachment.html


More information about the gdal-dev mailing list