Skip to content

Instantly share code, notes, and snippets.

@irees
Created November 19, 2015 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irees/1d23a13aae1d1a5937f2 to your computer and use it in GitHub Desktop.
Save irees/1d23a13aae1d1a5937f2 to your computer and use it in GitHub Desktop.
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