[gdal-dev] OGR Spatial reference conversion
Christiaan Janssen
cjanssen at iavo-rs.com
Thu Feb 21 09:14:17 EST 2008
Here's a snippet of code I used to test the conversion from one spatial reference system to another:
int err;
double x, y, z;
OGRCoordinateTransformation* ctTrans;
OGRSpatialReference* srFeet = new OGRSpatialReference();
OGRSpatialReference* srMeter = new OGRSpatialReference();
srFeet->SetStatePlane(3200, 1, SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV)); //NAD83 North Carolina
srMeter->SetStatePlane(3200, 1, SRS_UL_METER, 1.0); //NAD83 North Carolina
ctTrans = OGRCreateCoordinateTransformation(srFeet, srMeter);
x = 618067.37752800086;
y = 248532.06376793334;
z = 1210.7631359994411;
err = ctTrans->Transform(1, &x, &y, &z);
//Results from function call
//x = 188387.31344515912 <-Correct
//y = 75752.724541875374 <-Correct
//z = 1210.7631359994411 <-Wrong
//err = 1
If anyone could help to understand what I am doing wrong I'd greatly appreciate it... and thanks for the help thus far.
Christiaan
-----Original Message-----
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Christiaan Janssen
Sent: Wednesday, February 20, 2008 7:38 PM
To: Frank Warmerdam
Cc: gdal-dev at lists.osgeo.org
Subject: RE: [gdal-dev] OGR Spatial reference shifting
As it turns out the issue was a false easting due to not supplying the unit type in the setStatePlane function. After using the setStatePlane function I called the setLinearUnits which apparently didn't have the same effect (understandly). Now... another issue, I'm using the OGRCoordinateConversion function to convert from NAD83 StatePlane 3200 meters to NAD83 StatePlane 3200 feet and everything is correct except the Z value is not being converted. Any clue on this one. Thanks all for the help.
Christiaan
-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Wednesday, February 20, 2008 7:10 PM
To: Christiaan Janssen
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] OGR Spatial reference shifting
Christiaan Janssen wrote:
> Does anyone else notice issues using the coordinate conversion in OGR
> Spatial Reference. When I try to convert from a state plane system in
> US feet to WGS84 Lat/Lon everything is shifted about 1.75 degrees to
> the east. Specifically I'm converting Nad83 State Plane 101 (Alabama
> East) US Feet to WGS84 Lat/Lon meters. Maybe this is a Proj.4 issue
> but I'm not sure, any help would be greatly appreciated.
Christiaan,
There are many things that can go wrong. :-(
Can you be more specific about exactly what you are doing, how you are specifying the input and output coordinate system, what results you get (ie. a sample point in and out) and why you believe the result is wrong?
1.75 degrees is a big error, so it clearly isn't a datum shifting error.
It could be a linear units issue (feet vs. meters) for either the false easting/northings or the actual values being transformed.
Best regards,
--
---------------------------------------+--------------------------------
---------------------------------------+------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list