1

I have found this code in stack overflow to do Azimuthal equidistant projection and create a buffer polygon in Python.

    aeqd_proj = '+proj=aeqd +lat_0={lat} +lon_0={lon} +x_0=0 +y_0=0'
    project = partial(
        pyproj.transform,
        pyproj.Proj(aeqd_proj.format(lat=lat, lon=lon)),
        pyproj.Proj(4326))
    buf = Point(0, 0).buffer(km * 1000)  # distance in metres
    return transform(project, buf).exterior.coords[:]

Can someone please point out any libraries/indicators on how to do this Ruby? lat, lng are latitude and longitude co-ordinates and km is the distance in km from the lat, lng co-ordinates for which the projection has to be done.

Sunil
  • 3,424
  • 2
  • 24
  • 25

2 Answers2

0

I will use the original answer referenced by you to match Python to ruby:

# I think you do not need this for ruby but seems to me like a curried function
# and if you ever need one in ruby use a curried Proc
from functools import partial 

# use the gem proj4rb (https://github.com/cfis/proj4rb)
import pyproj

# use the gem "rgeo-proj4" (https://github.com/rgeo/rgeo)
from shapely.ops import transform
from shapely.geometry import Point

proj_wgs84 = pyproj.Proj('+proj=longlat +datum=WGS84')


def geodesic_point_buffer(lat, lon, km):
    # Azimuthal equidistant projection
    aeqd_proj = '+proj=aeqd +lat_0={lat} +lon_0={lon} +x_0=0 +y_0=0'
    project = partial(
        pyproj.transform,
        pyproj.Proj(aeqd_proj.format(lat=lat, lon=lon)),
        proj_wgs84)
    buf = Point(0, 0).buffer(km * 1000)  # distance in metres
    return transform(project, buf).exterior.coords[:]
0

If I remember corretly, pyproj is just the PROJ4 library in c++ with python hooks. Try on the PROJ4 page and see if anyone made one with ruby hooks?

Iustinian Olaru
  • 1,231
  • 1
  • 13
  • 33