# Distance between two points is not proportional above or below the Equator

I am trying to develop a tool that would find a point (longitude, latitude) that would be located a chosen distance away to the left from given point using Python and `pyproj`. I am not very familiar with geodesic calculations and I have come up with an idea to use proportion to calculate the (long,lat) of the distant point using a given point and a reference point, that has the same latitude but different longitude:

``````from pyproj import Geod

def get_point_placed_distance_away_from_point(point, reference_point, distance):
geod = Geod(ellps="WGS84")
point_located_by_distance_away = {"type": "Point", "coordinates": None}

point_coordinates = point["coordinates"]
reference_point_coordinates = reference_point["coordinates"]
lats = [point_coordinates[1], reference_point_coordinates[1]]
lons = [point_coordinates[0], reference_point_coordinates[0]]
reference_distance = geod.line_length(lons, lats)

point_located_by_distance_away["coordinates"] = [point_coordinates[0] +
(reference_point_coordinates[0] -
point_coordinates[0]) * distance /
reference_distance, point_coordinates[1]]

return point_located_by_distance_away
``````

The method works for points located near the equator. However the further the points are located above or below the Equator, the bigger the error is. I do not understand why, since even if the ellipsis above equator is smaller, the reference distance should be enough to calculate the proportional distant point.

• did you check that your lat and long are not switched ? Feb 18, 2020 at 16:03
• Hi, yes I checked that. I am running the same function for different points to test it. The result is just as i described. When a point is near the equator the results are good and the further from Equator, the worse they are Feb 19, 2020 at 8:34
• I use geojson.io to find the points. for example those two points are a point and reference point exclusively: { "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ 29.520263671875, -4.926778627933801 ] } }, { "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ 36.463623046875, -4.926778627933801 ] } } The latitude is the second position in coordinates list. Feb 19, 2020 at 9:16
• Hmm this usage of cosine is what I do not understand. Do You mean that the "shift" is the error that will grow the further the points are from the Equator? Feb 20, 2020 at 11:00
• sorry, I made a mistake. Here is the equation : new_point[0] = point[0] - distance_km * 360/(40000*cos(point[1])) . This come from the approximation that the size of a parallel (=360°) is equal to the size (in km) of the equator multiply by the cos of the latitude. This assumes that the Earth is a sphere. Feb 20, 2020 at 12:56

The error probably comes from the fact that you must set the latitude of your reference point coordinate equal to the latitude of your point, otherwise the reference distance is not valid. In fact, you simply need to locate your reference point with a given shift in longitude:

``````lats = [point_coordinates[1], point_coordinates[1]]
lons = [point_coordinates[0], point_coordinates[0]-1]
reference_distance = geod.line_length(lons, lats)

point_located_by_distance_away["coordinates"] = [point_coordinates[0] - distance /
reference_distance, point_coordinates[1]]
``````
• Sorry for such a long response. I have tested this solution and yes, it gives more accurate results for short distances (like 1km). It turns out, geod.line_length() returns distance in metres. So when I multiplied the distance like this: point_located_by_distance_away["coordinates"] = [point_coordinates[0] - distance*1000 / reference_distance, point_coordinates[1]] to obtain point located given km distance away, the error was still growing the further to south or north the point was from the equator. Mar 5, 2020 at 11:51