Skip to content

Instantly share code, notes, and snippets.

@plablo09
Last active December 11, 2015 17:33
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 plablo09/b3ed77516481826e03ed to your computer and use it in GitHub Desktop.
Save plablo09/b3ed77516481826e03ed to your computer and use it in GitHub Desktop.
quick csv to geojson
import csv
import json
csv_data = csv.reader(open('MonthMap.csv', 'rb'), delimiter='\t')
features = []
for i, row in enumerate(csv_data):
try:
f = {
"type" : "Feature",
"id" : row[0],
"properties" : { "date" : row[3], "value" : row[4]},
"geometry" : {
"type" : "Point",
"coordinates" : [float(row[2]),float(row[1])]
}
}
features.append(f)
except:
pass
feature_collection = {
"type" : "FeatureCollection",
"features": features
}
with open('output.geojson', 'w') as outfile:
json.dump(feature_collection, outfile,indent=4, sort_keys=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment