Created
June 7, 2015 15:53
-
-
Save luqmaan/4caf8ac7d00e02d362d0 to your computer and use it in GitHub Desktop.
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
import json | |
import psycopg2 | |
conn = psycopg2.connect("dbname='bostongreenmap' user='django' host='localhost' password='django'") | |
cursor = conn.cursor() | |
with open('./data/city_of_austin_parks.json', 'r') as fh: | |
data = fh.read() | |
data = json.loads(data) | |
crs = data['crs'] | |
for feature in data['features']: | |
geometry = feature['geometry'] | |
geometry['crs'] = crs | |
cursor.execute('SELECT ST_AsText(ST_Transform(ST_GeomFromGeoJson(%s), 4326));', (json.dumps(geometry), )) | |
print(cursor.fetchall()) | |
cursor.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment