Shapely
Shapely was mentioned in the Well-known text (WKT) section for import and export ability. But, its true purpose is 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 focus on geometry manipulation.
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, geometry >>> 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
We can then perform...