turfpy icon indicating copy to clipboard operation
turfpy copied to clipboard

incorrect measurement due to swap of lat/long

Open our30K opened this issue 3 years ago • 0 comments

Hi, thanks for all the work, I've been using this for a while, and recently I discover an issue about the points measurement

in the measure function, the comments shows that points should be defined as (lat, long) but in the calculation below, it is expecting (long, lat). which leads distance calculation error. this is an easy fix, but I am not sure, if this also leads to calculation error in point to line, point to polygon etc.

dlat = radians((coordinates2[1] - coordinates1[1])) dlon = radians((coordinates2[0] - coordinates1[0]))

" :param point1: first point; tuple of (latitude, longitude) in decimal degrees. :param point2: second point; tuple of (latitude, longitude) in decimal degrees. :param units: A string containing unit, E.g. kilometers = 'km', miles = 'mi', meters = 'm', feet = 'ft', inches = 'in'. :return: The distance between the two points in the requested unit, as a float. Example: >>> from turfpy import measurement >>> from geojson import Point, Feature >>> start = Feature(geometry=Point((-75.343, 39.984))) >>> end = Feature(geometry=Point((-75.534, 39.123))) >>> measurement.distance(start,end) """ coordinates1 = get_coord(point1) coordinates2 = get_coord(point2)

dlat = radians((coordinates2[1] - coordinates1[1]))

dlon = radians((coordinates2[0] - coordinates1[0]))

lat1 = radians(coordinates1[1])

lat2 = radians(coordinates2[1])"

our30K avatar Jun 03 '22 02:06 our30K