Comments (12)
I can't show the original two points but I chose two arbitrary points roughly ten km from each other. I'm getting roughly the same result.
point a: POINT (-77.220888 39.168931)
point b: POINT (-77.150249 39.219669)
degreesDistance: 0.086972483953261043 (this I get just using the .Distance() method on the IPoint)
degreesToMeters: 9682.2117760967849
transform: 10701.365215911384 (wgs84 to Popular Visualisation CRS / Mercator)
haversine: 961.83508919368637 (i suspect there's something wrong with the formula here)
PostGIS: 8376.15057906345
meridianoutpost.com: 8.3 km
.movable-type.co.uk/scripts/latlong.html: 8.3km (haversine calculator)
from projnet4geoapi.
You can calculate the UTM zone using the following formula:
public static int CalcUtmZone(double lon) => (int) ((lon + 180.0)/6.0 + 1.0);
You need to make sure that the used projection is suitable for the input points.
SharpMap has a geospatial math utility class that might help
from projnet4geoapi.
Could you post the actual coordinates of pointA
and pointB
?
from projnet4geoapi.
I'm afraid Lambert_Azimuthal_Equal_Area
projection is not supported (in targetWkt
).
How did you get a result in the first place, I get NotSupportedException
?
from projnet4geoapi.
Oh I did. It's just one of the many projections I tried. I was going through them one by one copy/pasting the WKT of any that had a unit of 'meters' trying to get something that made sense.
from projnet4geoapi.
var originCoordinateSystem = GeographicCoordinateSystem.WGS84;
var targetCoordinateSystem = ProjectedCoordinateSystem.WGS84_UTM(18, true);
var transform = transformationFactory.CreateFromCoordinateSystems(
originCoordinateSystem, targetCoordinateSystem);
var pointA = new GeoAPI.Geometries.Coordinate(-77.220888, 39.168931);
var pointB = new GeoAPI.Geometries.Coordinate(-77.150249, 39.219669);
var pointACoordinate = new GeoAPI.Geometries.Coordinate(pointA.X, pointA.Y);
var pointBCoordinate = new GeoAPI.Geometries.Coordinate(pointB.X, pointB.Y);
var newPointA = transform.MathTransform.Transform(pointACoordinate);
var newPointB = transform.MathTransform.Transform(pointBCoordinate);
double result = newPointB.Distance(newPointA);
Console.WriteLine($"Distance between {pointA} and {pointB} = {result}");
produces
Distance between (-77.220888, 39.168931, NaN) and (-77.150249, 39.219669, NaN) = 8305,08674556441
from projnet4geoapi.
Hrm....Getting a 'No support for transforming between the two specified coordinate systems' exception on the line where we call .CreateFromCoordinateSystems().
from projnet4geoapi.
Also hrm... looking at what Universal Transverse Mercator coordinate system for zone 18.... (first time I've heard of it but google provides)
How do you determine what zone the points you're looking at are in? What if one point is in one zone and the second point is in another zone?
from projnet4geoapi.
I have a similar class that calculates distance using similar methods. I'm just trying to understand how to do it using transforms. I had guessed that you transform both points into a projection that has it's units in meters and then just get the distance between them. Is that not how it works?
I wanna say I appreciate your help. I hate not understanding things.
from projnet4geoapi.
To compute the distance between two projected coordinates, you need to make sure that
- both are projected into the same spatial coordinate system
- the used spatial coordinate system is suitable for the distance calculations (it does not make sense to use EPSG:31467 when your coordinates are in Australia)
from projnet4geoapi.
right oranges to oranges.... but they are, aren't they? They're converted to WGS84 UMT... but then there's zone. Do you just put them in the same zone? or does that not matter because it's all WGS84 UMT?
from projnet4geoapi.
A different UTM Zone is a different spatial reference system. The error might be negligable when you have neighboring UTM zones, but as a rule of thumb, avoid that.
See https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Overlapping_grids
from projnet4geoapi.
Related Issues (20)
- Add Orthographic Projection HOT 2
- Handle WKT Extension Tag HOT 1
- License change to MIT HOT 3
- Coordinate Conversion - WGS84 to SPCS (NAD83) HOT 3
- Latitude & Longitude order confusing HOT 1
- Convert map view objects to svg
- How can i transforme a point from EPSG:2154 to EPSG:3857 ?
- Getting an error saying PROJCRS not recognized HOT 1
- How convert proj4js source to this lib source?
- Typo in code sample on Wiki HOT 1
- Migrate to Proj.6
- WGS84 -> Lambert Azimuthal Equal Area -> WGS84 fails when x = 0 HOT 3
- Add support for EPSG 5515 S-JTSK/05 / Modified Krovak HOT 2
- confusing documentation for axis orientation
- ProjNET only supports [] objects
- Release version ?
- Sqlite/sqlserver server side vs client side evaluation
- creating a transformation factory fails on ios HOT 1
- Add support of modern coordinate systems that includes height HOT 4
- Seeking help HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from projnet4geoapi.