[Proj] Coordinate transformation assistance

Frank Warmerdam warmerdam at pobox.com
Thu Apr 12 11:31:14 EDT 2007


Bjørn Krangnes wrote:
> Hi,
> 
> I am trying to go from Irish Transverse Mercator to IrishGrid75 Ireland
> using GDAL C# and EPSG codes.
> 
> The code is like this:
> 
> 
>             double[] xyz = new double[3];
> 
>             OGR.SpatialReference inp = new OGR.SpatialReference(null);
>             OGR.SpatialReference outp = new OGR.SpatialReference(null);
> 
> 
>             int stat1 = inp.ImportFromEPSG(2157);   // Irish Transverse
> Mercator
>             int stat2 = outp.ImportFromEPSG(29903); // IrishGrid75 Ireland
> 
>             OGR.CoordinateTransformation tra = new
> OGR.CoordinateTransformation(inp, outp);
> 
>             xyz[0] = 600000.0;
>             xyz[1] = 700000.0;
>             xyz[2] = 22.22;
> 
>             tra.TransformPoint(xyz);
> 
> I think the problems is with ImportFromEPSG because both istat1 and istat2
> is 6 after execution. How to initialize the EPSG codes ?
> 
> I am resending this request beacuse I have not had any feedback on my
> previous request.

Bjørn,

You don't indicate what the transformed result is or why you think there
is an error.  But if ImportFromEPSG() is failing (result 6 is
OGRERR_FAILURE) then it is likely because the EPSG .csv files aren't
being found.  One way around this is to set the GDAL_DATA environment
variable to point to the directory where the files like pcs.csv and gcs.csv
live.  In the source distribution they are in the gdal\data directory.

I think you can also do something like:

   Gdal.PushFinderLocation("C:\\gdal\\data");

or

   Gdal.SetConfigOption( "GDAL_DATA", "C:\\gdal\\data" );

though my csharp-gdal-fu is weak.

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



More information about the Proj mailing list