Last active
December 18, 2015 07:19
-
-
Save chaudum/8a7297838593287195b0 to your computer and use it in GitHub Desktop.
This script converts the countries.geo.json from https://github.com/johan/world.geo.json/blob/master/countries.geo.json> into JSON that can be imported into Crate.IO. You could actually use it with any country in this repository, such as Austria (AUT, https://github.com/johan/world.geo.json/blob/master/countries/AUT.geo.json)
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
# -*- coding: utf-8; -*- | |
# vi: set encoding=utf-8 | |
import sys | |
import json | |
def main(source): | |
with open(source) as fp: | |
d = json.load(fp) | |
for country in d['features']: | |
print(json.dumps(dict( | |
id=country['id'], | |
name=country['properties']['name'], | |
geometry=country['geometry'], | |
))) | |
if __name__ == '__main__': | |
""" | |
This script converts the ``countries.geo.json`` from | |
`johan/world.geo.json<https://github.com/johan/world.geo.json/blob/master/countries.geo.json>`_ | |
into JSON that can be imported into Crate.IO | |
Usage: python convert.py countries.geo.json | gzip -vc > countries.json | |
""" | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment