Geometric Functions

GeoDesk provides several Mercator-aware replacements for common Shapely measurement and constructive functions.

The functions described below are easier to use and are often faster than their Shapely equivalents, as they avoid the need for constructing temporary Geometry objects and converting measurements into the Cartesian units expected by Shapely.

In addition to Shapely Geometry objects, these functions accept Feature, as well as Box and Coordinate (where meaningful).

The following units may be used:

Length

  • meters (m)
  • feet (ft)
  • yards (yd)
  • kilometers (km)
  • miles (mi)

Area

  • square_meters (m2)
  • square_feet (ft2)
  • square_yards (yd2)
  • square_kilometers (km2)
  • square_miles (mi2)
  • hectares (ha)
  • acres (ac)

Length units such as m or ft are also accepted and treated as their area equivalent.

Measurement

geodesk.area(geom, units='square_meters')

Computes the area of a Geometry, Box or Feature.

Since 2.2

geodesk.length(geom, units='meters')

Computes the length of a (multi)linestring or polygon perimeter.

geom can be a Geometry or Feature

Since 2.2

geodesk.distance(geom1, geom2, units='meters')

Computes the distance between two Geometry, Feature, Box or Coordinate objects.

Since 2.2

Constructive operations

geodesk.buffer(geom, distance, units='meters')

Computes the buffer (a polygonal Geometry) of a Geometry, Feature, Box or Coordinate.

distance may be negative. A negative buffer may produce an empty geometry.

Example:

buf = buffer(geom, 20, 'feet')

Since 2.2

Adapted from Shapely Documentation — © 2011 – 2023 Sean Gillies and Shapely contributors. Licensed under CC-BY 3.0 US