I want to obtain the points of a LineString that are at a distance of 25m from the first point and from the last one of said LineString. I was doing some tests to check whether or not Shapely could be used for this task by using interpolate() and found a discrepancy between the real segment distance and the distance given by Shapely.
I have a LineString going from (40.41475479999999, -3.688968499999999) to (40.4139832, -3.6889473). If I calculate the distance between these two points using shapely.distance() the result is 0.000771, but calculating the distance with any other method, such as geopy.distance.geodesic().m returns the real distance, 85.68m.
The decimals differ, but I would not mind it if Shapely returned something like 0.000857, I would just need to remove the 0s to get the actual value.
Why is Shapely giving a completely different value? I'll leave some code below for anyone wanting to check for themselves.
import geopy.distance
import shapely
dist1 = shapely.distance(shapely.Point((40.41475479999999, -3.688968499999999)), shapely.Point((40.4139832, -3.6889473)))
dist2 = geopy.distance.geodesic((40.41475479999999, -3.688968499999999), (40.4139832, -3.6889473)).m
print("Shapely distance: {} - Geodesic distance: {}".format(dist1, dist2))
Shapely.distance()returns the cartesian distance in degrees in this case which is pretty much useless. you might want to check out https://gis.stackexchange.com/questions/403637/convert-distance-in-shapely-to-kilometres – Kalak Feb 08 '24 at 11:18