Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download the shapefiles contained in the Marco geoestadístico 2010 versión 5.0.A
#! /bin/bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Purpose: Download the shapefiles contained in the Marco geoestadístico 2010 versión 5.0.A
# comunicaciones y transportes
# cultura
# curvas de nivel
# hidrografia
# infraestructura
# marco cartografico nacional
# rasgo orografico
# territorio insular
# Note that you'll need a recent version of innoextract
# http://constexpr.org/innoextract/, one that can work with files
# created by version 5.5 of Inno Setup, the one in Ubuntu universe is
# not recent enough. The version available at
# https://launchpad.net/~arx/+archive/release is good enough.
# sudo add-apt-repository ppa:arx/release
# sudo apt-get update
# sudo apt-get install innoextract
# chmod +x mapa_digital_5.0.A.sh
# The script will create a directory called 'mapa_digital_5.0.A' where all
# the shapefiles are located, if something goes wrong when dowloading
# be sure to delete it and try again
# Projection compatible with Google Maps
PROJECTION_GOOGLE="+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
#INEGI
PROJECTION_INEGI="+proj=lcc +lat_1=17.5 +lat_2=29.5 +lat_0=12 +lon_0=-102 +x_0=2500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
curl --output Instalador_proyecto_basico_de_informacion.zip "http://www3.inegi.org.mx/geo/contenidos/MapaDigital/exe/Instalador_proyecto_basico_de_informacion.zip?idusr=80085"
unzip Instalador_proyecto_basico_de_informacion.zip
echo "Extracting shapefiles..."
innoextract --lowercase --silent Instalador_proyecto_basico_de_informacion.exe
echo "Reprojecting shapefiles..."
#Some shap files came with corrupted .prj files, force PROJECTION_INEGI
find . -name '*.shp' -execdir ogr2ogr {} {} -overwrite -s_srs "$PROJECTION_INEGI" -t_srs "$PROJECTION_GOOGLE" \;
mv "app/proyecto basico de informacion" "mapa_digital_5.0.A"
rm -rf app
rm -rf tmp
rm Instalador_proyecto_basico_de_informacion*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment