Shapely
Shapely was mentioned in the Well-Known Text (WKT) section for its import and export functions. However, its true purpose is as a generic geometry library. Shapely is a high-level, Pythonic interface to the GEOS library for geometric operations. In fact, Shapely intentionally avoids reading or writing files. It relies completely on data import and export from other modules and maintains its focus on geometry manipulation. You can install shapely
using conda
.
Let’s do a quick Shapely demonstration in which we’ll define a single WKT polygon and then import it into Shapely. Then, we’ll measure the area. Our computational geometry will consist of buffering that polygon by a measure of five arbitrary units, which will return a new, bigger polygon for which we’ll measure the area:
from shapely import wkt wktPoly = "POLYGON((0 0,4 0,4 4,0 4,0 0))" poly = wkt.loads(wktPoly) poly.area 16.0 buf = poly.buffer(5.0) buf.area 174.41371226364848...