Created
August 15, 2013 21:52
-
-
Save jwass/6245313 to your computer and use it in GitHub Desktop.
Simple Shapefile to GeoJSON converter. Using the shapefile from here:
http://www.mass.gov/anf/research-and-tech/it-serv-and-support/application-serv/office-of-geographic-information-massgis/datalayers/senate2012.html it will result in an error "ValueError: Record's geometry type does not match collection schema's geometry type: 'Polygon' != 'Unk…
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
import fiona | |
import fiona.crs | |
def convert(f_in, f_out): | |
with fiona.open(f_in) as source: | |
with fiona.open( | |
f_out, | |
'w', | |
driver='GeoJSON', | |
crs = fiona.crs.from_epsg(4326), | |
schema=source.schema) as sink: | |
for rec in source: | |
sink.write(rec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment