New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The distance calculated from point projections and linear distance is different and difference is big #551
Comments
The linear distance is about 65 meters and the shape is almost straight. |
JTS is a library for doing geometry/topology, not geography. How are you projecting the above geometries? Distance in JTS is in the units of whatever the values of the coordinates are in. If you ask for distance using longitude / latitude, you get back distance in degrees (which isn't entirely sensible, but can be slightly useful). |
Coordinate vehicleCoordinate = new Coordinate(vehicleLon, vehicleLat); This how I make my calculations. |
Ok, the first point is clearly on the line (since it is one of the vertices). Do you expect that the second point is on the line? |
What I do is I project the second point onto the shape, measure the difference between two projections by subtracting, and then convert the result to meters |
the projection distance gives me 92 meters and the straight line distance is just 65 meters, I wonder why the difference is that big. |
Your |
Is there a way to correctly calculate the distance in meters between start point to desired point along the route? |
what is the EPSG used in the library? |
It is whatever is used by the coordinates you provide. JTS itself simply assumes you are using a planar coordinate system. |
Assuming a very short distance, you can convert distance in degrees at a given latitude to metres using:
|
Please close if this has helped. |
Hello
I am projecting two points onto the shape and trying to calculate the distance between two projections. I also calculated the distance between two coords . Two distances differ and the difference is big. Can you please help me to find a mistake or prove that it is expected result in calculations.
the shape : LINESTRING (174.76716 -36.84489, 174.76715 -36.84489, 174.76719 -36.84481, 174.76598196955078 -36.84449656507264)
point one: "lon": 174.76716, "lat": -36.84489,
point two: "lon": 174.76646666666667, "lat": -36.844705,
point one projection: 0.0
point two projection: 8.286513887779961E-4
the difference between two projections is converted to meters and is equal to 92.2450506439055
Please confirm that my calculations are correct or wrong
With kind regards
The text was updated successfully, but these errors were encountered: