[Gdal-dev] SetStatePlane newbie question

Mote, Kevin D Kevin.Mote at pnl.gov
Fri Mar 31 22:44:07 EST 2006


 
I'm new to OGR/GDAL. I've been tasked with creating a simple module that
will transform State Plane coordinates to lat/lon.
 
This code is my first stab at it:

	#include <gdal.h>
	#include <gdal_priv.h> 
	#include <ogr_api.h>
	#include <ogr_spatialref.h>

	//Perform our inverse conversion:
	OGRSpatialReference sourceSRS;
	OGRSpatialReference destinationSRS;
	OGRCoordinateTransformation* pTransform;

	OGRErr err;
	err = sourceSRS.SetStatePlane(3102, true);
	ASSERT( err == OGRERR_NONE );
	err = destinationSRS.SetWellKnownGeogCS("WGS84"); 
	ASSERT( err == OGRERR_NONE );

	pTransform =
OGRCreateCoordinateTransformation(&sourceSRS,&destinationSRS);
	if (pTransform != NULL) 
	{
		double x = (double)x_value;	//values from elsewhere
		double y = (double)y_value;
		OGRErr err = pTransform->Transform(1, &x, &y, NULL);
		if (err != OGRERR_NONE)
			TRACE("%s\n", CPLGetLastErrorMsg());
		
		TRACE("Transform Result: %f %f  \n", x, y);
		delete pTransform;    
	}


Problem: The SetStatePlane() call is returning an error code of 6
(OGRERR_FAILURE).
What am I doing wrong? (I'm sure there's a number of things!)

Thanks in advance for any advice you might have!

Kevin 
Starlight Development Team, 
Computational & Information Sciences Directorate, 
Pacific Northwest National Laboratory 
(509) 372-4113 






More information about the Gdal-dev mailing list