Created
June 2, 2016 15:02
-
-
Save varunity/afbe457adae25a46b041ab92e745bda4 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
#!/usr/bin/python | |
import csv | |
import sys | |
import shapely.wkt | |
import geojson | |
csv.field_size_limit(sys.maxsize) | |
csvfile = open('in.csv', 'rb') | |
reader = csv.DictReader(csvfile) | |
c = csv.DictWriter(open("out.csv", "wb"), fieldnames=reader.fieldnames) | |
c.writeheader() | |
for row in reader: | |
for col in row: | |
if col == 'WKT': | |
d_wkt = row['WKT'] | |
js1 = shapely.wkt.loads(d_wkt) | |
js2 = geojson.Feature(geometry=js1, properties={}) | |
row['WKT'] = js2.geometry | |
c.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment