I'm working with shapely to do GIS, but I'm running into memory errors when loading the geometry of each zip code into memory because the geometry is so jagged and complicated.
I'd like to make the shape smaller in memory by reducing the number of boundary points as low as possible without distorting the shape too much. Using the convex hull seems like one potential answer, as could simply throwing away lots of points from the boundary. I'm wondering if there's something already out there that solves this problem.
Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries.
A LineString has zero area and non-zero length. >>> from shapely.geometry import LineString >>> line = LineString([(0, 0), (1, 1)]) >>> line. area 0.0 >>> line. length 1.4142135623730951. Its x-y bounding box is a (minx, miny, maxx, maxy) tuple.
unary_union. Returns a geometry containing the union of all geometries in the GeoSeries .
Try using the geometry's simplify method, specifying a tolerance distance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With