[gdal-dev] Re: C# Nad27 to WGS 84

Tomas R monshi at home.se
Sun Jul 12 14:30:44 EDT 2009


I might do something wrong...
 I just grab whatever Proj-file I find, I have not compiled it myself. 
Unsure witch version I was using when I posted the Q but now I use the 
one found in the latest build at http://trac.osgeo.org/proj/ 
(proj446_win32_bin.zip)
With that version I get a promising error: failed to load NAD27-83 
correction file
one step in the right direction....I fails to load....

What do I miss? Wrong version of Proj4? Do I need to compile the 
proj-file also? Perhaps should try one of your builds of gdal...
Miss in the setting of the environment variable?  I do it in the same 
way I set the GDal path, that is.
nadPath = 
Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), 
@"Gdalbin\Nad");
Environment.SetEnvironmentVariable("PROJ_LIB", nadPath);

and it checks out as expected if I try to grab the PROJ_LIB environment 
variable.

Note, the previous used (unknown version at this time) do not throw that 
error, any error than the erroneous result that is.

Thank for the, as always, quick and informative reply.

Yours
Tomas
Frank Warmerdam skrev:
> Tomas R wrote:
>> Hi again,
>>
>> New problems arises as the world of Gdal is quite complex to grasp.
>>
>> Have understood that the transformation of coordinates from Nad 27 
>> datum to WGS 84 requires some look up tables to be done correctly, 
>> tables that differ with the are the Nad 27 is valid in.
>>
>> Simple question is, how to set up a general solution in C# that uses 
>> these shift tables.
>> I have in code a simple test:
>>           SpatialReference spatNad27 = new SpatialReference("");
>>            spatNad27.SetWellKnownGeogCS("Nad27");
>>            SpatialReference spatNad83 = new SpatialReference("");
>>            spatNad83.SetWellKnownGeogCS("Nad83");
>>                      CoordinateTransformation trans = new 
>> CoordinateTransformation(spatNad27, spatNad83);
>>            double[] p = new double[3];
>>            trans.TransformPoint(p, -117, 30, 0);
>>
>> that gives back
>> -117, 30,0000000008175
>> which I believe is not correct ( see http://proj.maptools.org/faq.html )
>>
>> I have Proj4.dll, I have set an environment path to PROJ_LIB where 
>> the nad shift tables should exist. Must I do something else in the 
>> setup or is the call to the transform different? or have I done 
>> correctly but misinterpreted the results?
>>
>> What I in reality is interested is transforming whatever coordinate 
>> in whatever projection/datum to and from WGS84 without any extra 
>> hassle fast and easy via the C# interface. That should not be to 
>> hard? Or?
>
> Tomas,
>
> If I test with the testepsg program (using GDAL services) with
> CPL_DEBUG and PROJ_DEBUG defined ON I get the following output.
>
> warmerda at gdal64[264]% setenv PROJ_DEBUG
> warmerda at gdal64[265]% testepsg -t NAD27 NAD83 -117 30
> OGRCT: Source: +proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
> OGRCT: Target: +proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs
> pj_open_lib(conus): call 
> fopen(/wrk/home/warmerda/bld/share/proj/conus) - succeeded
> Ctable Conterminous United States 273x121: LL=(-131,20) UR=(-63,50)
> pj_open_lib(alaska): call 
> fopen(/wrk/home/warmerda/bld/share/proj/alaska) - succeeded
> Ctable Alaska 529x249: LL=(-194,46) UR=(-128,77)
> pj_open_lib(ntv2_0.gsb): call 
> fopen(/wrk/home/warmerda/bld/share/proj/ntv2_0.gsb) - failed
> pj_open_lib(ntv1_can.dat): call 
> fopen(/wrk/home/warmerda/bld/share/proj/ntv1_can.dat) - succeeded
> NTv1 393x177: LL=(-142,40) UR=(-44,84)
> pj_open_lib(conus): call 
> fopen(/wrk/home/warmerda/bld/share/proj/conus) - succeeded
> pj_apply_gridshift(): used Conterminous United States
> (-117.000000,30.000000,0.000000) -> (-117.000806,30.000113,0.000026)
>
> I don't know if it is practical for you to enable debugging and see
> stderr output, but if you can it might help you deduce what is
> or is not working.
>
> It *sounds* like you have done what is necessary, but it is hard
> for me to know if you have made some mistake, such as preprocessing
> the grid shift file into binary form.
>
> Best regards,



More information about the gdal-dev mailing list