Giter VIP home page Giter VIP logo

Comments (12)

eiredrake avatar eiredrake commented on June 22, 2024 1

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.

FObermaier avatar FObermaier commented on June 22, 2024 1

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.

FObermaier avatar FObermaier commented on June 22, 2024

Could you post the actual coordinates of pointA and pointB?

from projnet4geoapi.

FObermaier avatar FObermaier commented on June 22, 2024

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.

eiredrake avatar eiredrake commented on June 22, 2024

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.

FObermaier avatar FObermaier commented on June 22, 2024
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.

eiredrake avatar eiredrake commented on June 22, 2024

Hrm....Getting a 'No support for transforming between the two specified coordinate systems' exception on the line where we call .CreateFromCoordinateSystems().

from projnet4geoapi.

eiredrake avatar eiredrake commented on June 22, 2024

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.

eiredrake avatar eiredrake commented on June 22, 2024

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.

FObermaier avatar FObermaier commented on June 22, 2024

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.

eiredrake avatar eiredrake commented on June 22, 2024

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.

FObermaier avatar FObermaier commented on June 22, 2024

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)

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.