0

I have a polygon that consists of a few (lon, lat) points, each pair of consequent points is considered to be connected by orthodromes. I want to interpolate the polygon with some extra points between each source point pair (add some more waypoints lying on the orthodrome).

I know, that geopy, for example, has the possibility to calculate the distance on great circle, but I need some more: to find the waypoints on great circle.

I need something like that:

src_lon = 10
src_lat = 40

dst_lon = 20
dst_lat = 60

n_points = 100

lons, lats = interpolate_orthodrome(src_lon, src_lat, dst_lon, dst_lat, n_points)
  • In case it's helpful for someone else or for others who may know a Python equivalent, I found a Matlab equivalent gcwaypts: mathworks.com/help/map/ref/gcwaypts.html. – smiller Feb 7 at 14:19
  • This blog post has midpoint calculation on a great circle. Workaround: creating multiple (incremental) midpoints? samuelbosch.com/2014/05/working-in-lat-long-great-circle.html – smiller Feb 7 at 14:22
  • Well, I've already found a solution with pyproj: pyproj.Geod.npts function. – Felix Feb 7 at 14:23
  • 1
    Great. If you edit your question with a code attempt it will trigger the review queue to reopen your question, at which point it can be answered. Also another source for those looking for the mathematics behind these calculations: movable-type.co.uk/scripts/latlong.html – smiller Feb 7 at 14:25
  • Certainly. I've just added the solution to the question. – Felix Feb 7 at 14:30
0

UPD:

I have found a good solution: pyproj.Geod.npts:

from pyproj import Geod


lon0, lat0 = 10, 10
lon1, lat1 = 20, 20
n_extra_points = 100    

geoid = Geod(ellps="WGS84")
extra_points = geoid.npts(lon0, lat0, lon1, lat1, n_extra_points)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.