Coder Social home page Coder Social logo

tomasjohansson / crstransformations-dotnet Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 5.0 13.48 MB

Coordinate Reference System Transformations. This is a .NET library implemented with F#, but also usable from C#. Most of the test code is actually written with C#. The third-part libraries used from the F# code may also have been implemented with C#.

License: MIT License

F# 95.60% Visual Basic .NET 4.40%
gis crs transformations coordinates spatial srs transformation transform convert conversion

crstransformations-dotnet's People

Contributors

tomasjohansson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crstransformations-dotnet's Issues

Incorrect work of ProjNet 2.0 while crsTransformations works fine

Hello!
I found wierd issue with ProjNet and hope you can shed some light on it. I checked sources of crsTransformations, there is .csv file with WKT strings assigned to EPSG codes. In code you get WKT string by code (SridReader.fs) and use ProjNet classes to create CoordinateSystems and calculate result (CrsTransformationAdapterProjNet.fs).
In my project I have many coordinate systems without EPSG codes, so I use ProjNet with WKTs and calculate result. It gives correct result when I transform GEOCS to PROJCS, but if I try to calculate between GEOCS to GEOCS, I receive results with mistake ~100 meters.

Consider code (dead simple):

string ProjSk42 = " GEOGCS[\"Pulkovo 1942\",DATUM[\"Pulkovo_1942\",SPHEROID[\"Krassowsky 1940\",6378245,298.3,AUTHORITY[\"EPSG\",\"7024\"]],TOWGS84[23.92,-141.27,-80.9,0,0.35,0.82,-0.12],AUTHORITY[\"EPSG\",\"6284\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4284\"]]";
string ProjWgs84 = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
CoordinateSystemFactory qq = new CoordinateSystemFactory();

var wgs= qq.CreateFromWkt(ProjWgs84);
var sk42 = qq.CreateFromWkt(ProjSk42);
CoordinateTransformationFactory ctfac = new ();


ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems( wgs,sk42);   
 double[] fromPoint = { 66, 76 };
 double[] toPoint = trans.MathTransform.Transform(fromPoint); 

I tried many WKT strings, get them from your CSV, from epsg.io etc. Your lib uses same ProjNet classes:

let crs = _coordinateSystemFactory.CreateFromWkt(wellKnownText)
let trans: ICoordinateTransformation  = ctFact.CreateFromCoordinateSystems(sourceCrs, targetCrs)
let result: double[] = trans.MathTransform.Transform(xy)

So I dont understand why ProjNet gives me bad result while crsTransformations works great. Maybe you have some ideas about it? I even checked binary content of ProjNet.dll, it's same for both cases :/ I answered this question here and got answers that ProjNet is outdated.

Also a suggestion, can you provide a feature to construct coordinateSystem from WKT ?

ProjNet4GeoAPI adapter gives bad transformations

Hello. I am transforming coords from WGS 84 to Russian local systems (like EPSG:28406 Pulkovo 1942 / Gauss-Kruger zone 6).
I noticed that ProjNet4GeoAPI returns result which differs from EPGS calculations for about 70 meters or so. CrsTransformationAdapterDotSpatial saves the day and calculates exactly how EPGS.

code:

int epsgWgs84  = EpsgNumber.WORLD__WGS_84__4326;
//59°59'28.428"  30°45'16.428"
CrsCoordinate crsCoordinate = CrsCoordinateFactory.LatLon(59.991230000, 30.754563333, epsgWgs84);
var crsTransformationAdapter = new CrsTransformationAdapterProjNet4GeoAPI();
CrsTransformationResult centralStockholmResultSweRef = crsTransformationAdapter.Transform(crsCoordinate, 28406);
Console.WriteLine(centralStockholmResultSweRef.OutputCoordinate);  //6374685.338621391     6655336.4426284255
var crsTransformationAdapter2 = new CrsTransformationAdapterDotSpatial();
centralStockholmResultSweRef = crsTransformationAdapter2.Transform(crsCoordinate, 28406);
Console.WriteLine(centralStockholmResultSweRef.OutputCoordinate); //6374811.1527767507 6655337.1512627564

epsg gives 6374811.15 and 6655337.15

So why ProjNet4GeoAPI differs so much?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.