Skip to content

Commit

Permalink
Added remove_small_polygons operation for processor
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornd committed Jul 23, 2015
1 parent 6dc3908 commit 71761cf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions converter/processor.py
Expand Up @@ -551,6 +551,16 @@ def intersect_rect(self, config, data_source):
for geometry in data_source.geometries:
geometry.geom = geometry.geom.intersection(rect)

def remove_small_polygons(self, config, data_source):
for geometry in data_source.geometries:
if isinstance(geometry.geom, shapely.geometry.multipolygon.MultiPolygon):
polygons = geometry.geom.geoms
else:
polygons = [geometry.geom]
polygons = filter(lambda p: p.area > config['minimal_area'], polygons)
if len(polygons) > 0:
geometry.geom = shapely.geometry.multipolygon.MultiPolygon(polygons)


args = {}
if len(sys.argv) > 1:
Expand Down

0 comments on commit 71761cf

Please sign in to comment.