[Proj] Coordinate transformation assistance

Bjørn Krangnes bkr at devonor.com
Fri Apr 13 00:25:44 PDT 2007


Frank,
I have been trying what you suggested but no luck. I added the code line
"GDAL.gdal.SetConfigOption("GDAL_DATA", "D:\\gdal-1.4.0\\data");", also
tried Gdal.PushFinderLocation with no luck before calling ImportFromEPSG.
In this directory is all files from the source distribution data
directory. There is no EPSG file in this directory. I did find one EPSG
file in the source distribution for "proj-4.5.0\nad" catalog.
I copied this file to "D:\\gdal-1.4.0\\data" but still no luck. When
stepping though code line "OGR.CoordinateTransformation tra = new
OGR.CoordinateTransformation(inp, outp);" I get an
"AccessViolationException was unhandled" error.
The expected result is Easting:200049.410 Northing: 200049.410

Regards
Bjørn
> 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
>
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>


Bjørn Krangnes
Devonor AS
Telephone: +47 32 29 96 90
Direct Line: +47 32 29 96 91
Mobile: +47 45035640
E-mail: bkr at devonor.com
Web: www.devonor.com





More information about the Proj mailing list