Reputation: 141
I followed this article https://learn.microsoft.com/en-us/ef/core/modeling/spatial but is not working.
var seattle = new Point(-122.333056, 47.609722) { SRID = 4326 };
var redmond = new Point(-122.123889, 47.669444) { SRID = 4326 };
var distance = seattle.ProjectTo(2855).Distance(redmond.ProjectTo(2855));
This code is returning distance = 17062 meters
From websites Distance Calculator I'm getting distance = 17.02 kilometers
The distance is approximately the same for the example in the article.
But if I choose this coordinates:
var seattle = new Point(1.230469, 19.973349) { SRID = 4326 };
var redmond = new Point(17.753906, 19.642588) { SRID = 4326 };
var distance = seattle.ProjectTo(2855).Distance(redmond.ProjectTo(2855));
This code is returning distance = 1926891 meters
From websites, distance = 1,728 kilometers
The difference is 200 meters approx. I tested with other locations and the results are worse
In the article there is a comment: // Different data requires a different coordinate system.
What does it mean? Should I use another coordinate system than 2855? Which one?
Upvotes: 1
Views: 1527
Reputation: 5332
Have a look at UTM Zones (Univesal Transverse Mercator) as a starting point:
Generally, the smaller the region of the 3D earth you try to project onto a 2D map, the more accurate it will be. So in Microsoft's example, you could get okay accuracy using UTM 10 for seattle, but they are being even more precise using a specific Northern Washington projection
So for your case (Mali), try UTM 31. Make sure to copy the "Well Known Text" (WKT) into your example and reference that instead of the one for Northern Washington. Then, if that's not good enough, try searching for projections closer to your precise area of interest.
Upvotes: 2