Created
November 19, 2015 20:34
-
-
Save irees/1d23a13aae1d1a5937f2 to your computer and use it in GitHub Desktop.
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 sys | |
import json | |
import collections | |
FILENAME = sys.argv[1] | |
KEY = sys.argv[2] | |
with open(FILENAME) as f: | |
data = json.load(f) | |
split = collections.defaultdict(list) | |
for feature in data['features']: | |
split[feature['properties'][KEY]].append(feature) | |
for key, features in split.items(): | |
with open('split-%s.geojson'%key, 'w') as f: | |
json.dump({ | |
'type': 'FeatureCollection', | |
'features': features | |
}, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment