[Proj] cs2cs giving different result than ImportportFromProj4 in a C# program

support.mn at elisanet.fi support.mn at elisanet.fi
Fri Jan 28 04:50:37 EST 2011


Bjørn ,

all I can come up with in a short time is
this 16 digit number -> 6356034.447938534 ??

Are you sure that both versions can read all those digits?
Test both with shorter numbers?

Does both programs really get all the numbers exactly
the same. Make some tests and traces? What numbers
do those programs actually use?

Regards: Janne.

------------------------------------------

Bjørn Krangnes [bkr at devonor.com] kirjoitti: 
> cs2cs is giving this result (Irish Transverse Mercator to IrishGrid75):
> 
> C:\Program Files (x86)\FWTools2.4.7>cs2cs +proj=tmerc +lat_0=53.5 +lon_0=-8
> +k=0
> 
> .999820 +x_0=600000 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m
> +no
> 
> _defs +to +proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1.000035 +x_0=200000
> +y_0=250000
> 
> +a=6377340.189 +b=6356034.447938534
> +towgs84=482.530,-130.596,564.557,-1.042,-0.
> 
> 214,-0.631,8.15 +units=m +no_defs
> 
> 600000.0 700000.0
> 
> 200049.28       199965.72 -54.78
> 
>  
> 
> The correct result is:  E: 200049.410 N: 199965.743
> 
> The result from cs2cs is very close to the correct result.
> 
>  
> 
> But when I use the following code in a c# program the result is not the same
> as cs2cs
> 
>  
> 
> SpatialReference input = new OSGeo.OSR.SpatialReference(null);
> 
> SpatialReference output = new OSGeo.OSR.SpatialReference(null);
> 
>  
> 
> int istati = input.ImportFromProj4("+proj=tmerc +lat_0=53.5 +lon_0=-8
> +k=0.999820 +x_0=600000 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0
> +units=m +no_defs");   // ITM
> 
> int istato = output.ImportFromProj4("+proj=tmerc +lat_0=53.5 +lon_0=-8
> +k=1.000035 +x_0=200000 +y_0=250000 +a=6377340.189 +b=6356034.447938534
> +towgs84=482.530,-130.596,564.557,-1.42,-0.214,-0.631,8.15 +units=m +wktext
> +no_defs <>)");   // IG
> 
> CoordinateTransformation tra = new CoordinateTransformation(input, output);
> 
> double[] xy = new double[3];
> 
> xy[0] = 600000.0;
> 
> xy[1] = 700000.0;
> 
> xy[2] = 0;
> 
> tra.TransformPoint(xy);
> 
>  
> 
> After execution xy[0]= 200040.069 and xy[1]= 199964.097. This is about 9
> meters off in east and 1.7 in north.
> 
>  
> 
> Any reason why I should get 2 different results? 
> 
>  
> 
> Regards
> 
> Bjørn
> 
> 
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj



More information about the Proj mailing list