[Gdal-dev] Problem using EPSG in C#

Tomas R monshi at home.se
Tue May 8 10:27:54 EDT 2007


Sorry if this is a newbie question, but someone has to ask them to.

I'm trying to make use of the EPSG-codes in setting up a pair 
OGR.SpatialReference and an OGR.CoordinateTransformation.
I can make this work in one small test application but in the main one 
it just doesn't work.

Sample code:
  private CoordinateTransformation toWGS;
  private CoordinateTransformation fromWGS;
SpatialReference source;
SpatialReference wgs84;
   source = new SpatialReference("");
   int EPSG = 3021;
   int res = source.ImportFromEPSG(EPSG);

   wgs84 = new SpatialReference(Projections.WKT("WGS84"));
   fromWGS = new CoordinateTransformation(wgs84, source);
   toWGS = new CoordinateTransformation(source, wgs84);

where the wgs84 is set up from a WKT-string.

What I guess I miss is how to set up the paths and so between/to the 
different data files.
GDAL is located in FWTools\bin (on the PATH)
EPSG-catalouge in FWTools\Data (also on the PATH) and also copied to the 
  VSE project.
But how SHOULD it be? I stumble in darkness...

The result of the Import is by the way a 6.

Or how do you suggest I approach this, how do I set up the 
transformation? What "standard" is easiest for me to use? The goal of 
this application is to be able to map any projection (well, some) to 
WGS84 and back. The user is to be able to manually set projection and 
also be read from files (via GDALInfo is the idea).

pls.

Yours
Tomas




More information about the Gdal-dev mailing list