Skip to content

Instantly share code, notes, and snippets.

@dylanroy
Forked from tmcw/README.md
Created June 6, 2013 20:07
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 dylanroy/5724508 to your computer and use it in GitHub Desktop.
Save dylanroy/5724508 to your computer and use it in GitHub Desktop.
import csv
from shapely.geometry import Point, mapping
from fiona import collection
schema = { 'geometry': 'Point', 'properties': { 'name': 'str' } }
with collection(
"some.shp", "w", "ESRI Shapefile", schema) as output:
with open('some.csv', 'rb') as f:
reader = csv.DictReader(f)
for row in reader:
point = Point(float(row['lon']), float(row['lat']))
output.write({
'properties': {
'name': row['name']
},
'geometry': mapping(point)
})
name lat lon
Chicago 41.88 -87.63
Kansas City 39.101 -94.584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment