I have a polygon in Python shapely that I would like to buffer with a 100-foot buffer.

If the polygon is stored as a series of WGS84 lon/lat points how would I go about calculating the distance of the 100ft buffer?

I can't find anything searching online and seeking guidance on the algorithm.


2 Answers 2


First, I will assume that your points are in WGS84 = EPSG: 4326. Convert the lon/lat points to UTM meters using pyproj lib. First we need to get the correct projection. The issue is that to convert to UTM you need to know your UTM zone. That is something you can look up separately; UTM zone will depend on the longitude of the initial shape.

import pyproj
import shapely.geometry as shpgeo

proj = pyproj.Proj(proj="utm", zone=???, ellps="WGS84", datum="WGS84")

I used a standard helper function to convert Polygons and MultiPolygons to and from UTM. The arguments are a shapely Polygon or MultiPolygon object and a PyProj Proj object.

def toFromUTM(shp, proj, inv=False):
    geoInterface = shp.__geo_interface__
    shpType = geoInterface['type']
    coords = geoInterface['coordinates']
    if shpType == 'Polygon':
        newCoord = [[proj(*point, inverse=inv) for point in linring] for linring in coords]
    elif shpType == 'MultiPolygon':
        newCoord = [[[proj(*point, inverse=inv) for point in linring] for linring in poly] for poly in coords]
    return shpgeo.shape({'type': shpType, 'coordinates': tuple(newCoord)})

Using this function, you can convert your shape (initial_polygon) to UTM, buffer it in meters (100 feet is 30.48 meters), then convert back to lon/lat if you so desire

init_shape_utm = toFromUTM(initial_polygon, proj)
buffer_shape_utm = init_shape_utm.buffer(30.48)
buffer_shape_lonlat = toFromUTM(buffer_shape_utm, proj, inv=True)

The output will be a shapely Polygon (or MultiPolygon) buffered to 100 feet, with coordinates in the WGS84 lon/lat system.

  • This is such a life-saver. Created the gist here for quick reference for Indian UTM zone: gist.github.com/harshithjv/bcd3fef5661ce0a2ec20224e8e4ac415 Simplified the code with transform_wkt_with_buffer function that can be called with just two parameters, after configuring appropriate params to to proj object. Commented Jul 8, 2022 at 14:59

Pasting solution from similar question.

original answer: https://gis.stackexchange.com/a/289923/202057

from pyproj import CRS, Transformer
from shapely.geometry import Point
from shapely.ops import transform

def geodesic_point_buffer(lat, lon, km):
    # Azimuthal equidistant projection
    aeqd_proj = CRS.from_proj4(
        f"+proj=aeqd +lat_0={lat} +lon_0={lon} +x_0=0 +y_0=0")
    tfmr = Transformer.from_proj(aeqd_proj, aeqd_proj.geodetic_crs)
    buf = Point(0, 0).buffer(km * 1000)  # distance in metres
    return transform(tfmr.transform, buf).exterior.coords[:]
  • 1
    please don't use slang like tldr in your contributions. Commented Jun 26 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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