Created
September 7, 2011 15:34
-
-
Save swinton/1200890 to your computer and use it in GitHub Desktop.
Simple script to combine a bunch of GeoJson files that each specify a single Polygon into a MultiPolygon GeoJson object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Simple script to combine a bunch of GeoJson files that each specify a single Polygon into a MultiPolygon GeoJson object. | |
| """ | |
| import json, sys | |
| def combine(*args): | |
| combined = {"type": "MultiPolygon", "coordinates": []} | |
| for file in args: | |
| polygon = json.load(open(file)) | |
| combined["coordinates"].append(polygon["coordinates"]) | |
| json.dump(combined, sys.stdout) | |
| if __name__ == "__main__": | |
| combine(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment