Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Download the shapefiles contained in the Mapa Digital de México
#! /bin/bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Purpose: Download the shapefiles contained in the Mapa Digital de México
# 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 download-mapa-digital-shp.sh
# If you use a mac you should probably 'brew install wget' first
# The script will create a directory called 'mapa_digital' 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="+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
# wget command
WGET="wget -w 5 --random-wait --tries=2 "
# The mapa digital is available as 4 files
declare -a extensions=(".exe" "-1.bin" "-2.bin" "-3.bin")
for i in {0..3}
do
$WGET "http://www.inegi.org.mx/geo/contenidos/mapadigital/default.aspx?_file=/geo/contenidos/MapaDigital/exe/Instalador_Proyecto_informacion_basica${extensions[i]}&idusr=80085" -O instalador_proyecto_informacion_basica${extensions[i]}
sleep 20
done
echo "Extracting shapefiles..."
innoextract --lowercase --silent instalador_proyecto_informacion_basica.exe
echo "Reprojecting shapefiles..."
find . -name '*.shp' -execdir ogr2ogr {} {} -overwrite -t_srs "$PROJECTION" \;
mv "app/proyecto de informacion basica" "mapa_digital"
rm -rf app
rm -rf tmp
rm -rf instalador_proyecto_informacion_basica*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment