Last active
August 29, 2015 14:06
-
-
Save larrybuch/4c08adb8817f4d9773c3 to your computer and use it in GitHub Desktop.
batch convert shp files to geojson using ogr2ogr
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
# TAKEN FROM HERE https://gist.github.com/benbalter/5858851 | |
# Bulk convert shapefiles to geojson using ogr2ogr | |
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/ | |
# Note: Assumes you're in a folder with one or more zip files containing shape files | |
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere) | |
#geojson conversion | |
function shp2geojson() { | |
ogr2ogr -f geoJSON -t_srs crs:84 "output/$1.geojson" "$1.shp" | |
} | |
# unzip all files in a directory | |
# for var in *.zip; do unzip "$var"; done | |
#convert all shapefiles | |
for var in *.shp; do shp2geojson ${var%\.*}; done | |
# You'd probably want to `mv *.geojson [path-to-git-repo]/` at this point | |
# so you could commit the file to GitHub | |
# Happy mapping! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment