Skip to content

Instantly share code, notes, and snippets.

@whistler
Created April 6, 2018 02:47
Show Gist options
  • Save whistler/696968ae70449f7a708a1aa76794f304 to your computer and use it in GitHub Desktop.
Save whistler/696968ae70449f7a708a1aa76794f304 to your computer and use it in GitHub Desktop.
Merge two GeoJSON AOIs into one
from functools import reduce
import shapely.geometry
import geojson
def merge_aois(aois):
shapes = (shapely.geometry.asShape(aoi) for aoi in aois)
union = reduce(lambda a, b: a.union(b), shapes)
merged_aoi = geojson.Feature(geometry=union, properties={})
return merged_aoi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment