Created
April 5, 2022 18:07
-
-
Save zidel/4fbea3a3e7443fc734a2b1a6be87a999 to your computer and use it in GitHub Desktop.
Collapse geojson FeatureCollection
This file contains 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
import json | |
import sys | |
import zipfile | |
output = { | |
'type': 'FeatureCollection', | |
'properties': {}, | |
'features': [], | |
} | |
with zipfile.ZipFile(sys.argv[1]) as input_zip: | |
for name in input_zip.namelist(): | |
with input_zip.open(name) as input_geojson: | |
data = json.load(input_geojson) | |
issues = data['features'] | |
for issue in issues: | |
features = issue['features'] | |
for feature in features: | |
output['features'].append(feature) | |
json.dump(output, open(sys.argv[2], 'w')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment