Skip to content

Instantly share code, notes, and snippets.

@diegovalle
Last active June 11, 2020 00:36
Show Gist options
  • Select an option

  • Save diegovalle/5864549 to your computer and use it in GitHub Desktop.

Select an option

Save diegovalle/5864549 to your computer and use it in GitHub Desktop.

Revisions

  1. diegovalle revised this gist Jun 28, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions download-mapa-digital.sh
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,7 @@
    # 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
  2. diegovalle revised this gist Jun 27, 2013. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions download-mapa-digital.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,15 @@

    # 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
  3. diegovalle revised this gist Jun 26, 2013. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions download-mapa-digital.sh
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,9 @@
    # sudo apt-get install innoextract
    # chmod +x download-mapa-digital-shp.sh

    # As of now, this script has not been tested on Windows and Mac
    # systems, only on Ubuntu. 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
    # 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"
    @@ -37,7 +36,7 @@ done
    echo "Extracting shapefiles..."
    innoextract --lowercase --silent instalador_proyecto_informacion_basica.exe
    echo "Reprojecting shapefiles..."
    find . -maxdepth 8 -name '*.shp' -execdir ogr2ogr {} {} -overwrite -t_srs "$PROJECTION" \;
    find . -name '*.shp' -execdir ogr2ogr {} {} -overwrite -t_srs "$PROJECTION" \;
    mv "app/proyecto de informacion basica" "mapa_digital"
    rm -rf app
    rm -rf tmp
  4. diegovalle revised this gist Jun 26, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download-mapa-digital.sh
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@

    # As of now, this script has not been tested on Windows and Mac
    # systems, only on Ubuntu. The script will create a directory
    # called 'shps' where all the shapefiles are located, if something
    # 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
  5. diegovalle revised this gist Jun 26, 2013. No changes.
  6. diegovalle created this gist Jun 26, 2013.
    44 changes: 44 additions & 0 deletions download-mapa-digital.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #! /bin/bash
    # Author: Diego Valle-Jones
    # Web: http://www.diegovalle.net

    # Purpose: Download the shapefiles contained in the Mapa Digital de México

    # 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

    # As of now, this script has not been tested on Windows and Mac
    # systems, only on Ubuntu. The script will create a directory
    # called 'shps' 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 . -maxdepth 8 -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*