Skip to content

Instantly share code, notes, and snippets.

@wknowles
Created April 19, 2016 07:03
Show Gist options
  • Save wknowles/a1a90583ab3e97a4052504bb00d768c8 to your computer and use it in GitHub Desktop.
Save wknowles/a1a90583ab3e97a4052504bb00d768c8 to your computer and use it in GitHub Desktop.
quick script to clip and re-project a shapefile
#!/bin/bash
base_file='ne_50m_land' # change this to the filename of your shapefile
echo "clipping shapefile ${base_file}.shp"
ogr2ogr -f "ESRI Shapefile" ${base_file}_clipped.shp $base_file.shp -clipsrc -180 -85.06 180 85.06
echo "setting ${base_file} to web mercator projection"
ogr2ogr -t_srs EPSG:3857 ${base_file}_clipped_3857.shp ${base_file}_clipped.shp
echo "cleaning up redundant files"
rm ${base_file}.*
rm ${base_file}_clipped.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment