Shapefiles of Mexico (AGEBs, Manzanas, etc)

on Jun 24, 2013
[UpdateYou can now download the shapefiles directly from the data page without running the script]

My post on how to download electoral shapefiles proved to be very popular, so I've decided to create another script to download shapefiles of census geographies. This is all data that is freely available from the INEGI website, it's just that they make it really hard to find, it's only downloadable as a compressed windows executable, and the download links for the files tend to change every few months.

The shapefiles are encoded as codepage 1252 and will be reprojected to WGS84. All data corresponds to the 2010 census.

Now for the ugly bits: You'll need a recent version of innoextract, one that can work with files created by version 5.5 of Inno Setup (yes, the INEGI distributes shapefiles as windows installers), the one in Ubuntu universe is not recent enough. The version available at this repository should work.

sudo add-apt-repository ppa:arx/release
sudo apt-get update
sudo apt-get install innoextract

As of now, this script has not been tested on Windows and Mac systems, only on Ubuntu. This script has been tested on Ubuntu, on a Mac you should try and use 'brew install wget' and 'brew install rename' before running it, and on Windows use cygwin. The script will create a directory called 'shps' where all the shapefiles are located, if something goes wrong when downloading be sure to delete it and try again. Once you finish running the script you'll end up with about 5.5 gigabytes of shapefiles containing all available levels of geographical granularity for the 2010 Mexican census.

Census Geographies:
States -> Municipios (Counties) -> Localidades (Polygon if urban otherwise point) -> AGEB (Census Areas - Urban only) -> Manzana (Census Blocks - Urban only)

Plus, you'll also get a bunch of shapefiles of parks, rivers, schools and so on.


States

Municipios (Counties)

Localidades (Urban Polygons and Rural Points)



AGEB (Census Areas)
Federal District

Manzanas (Blocks)
Federal District


Ejes viales (Streets)
Federal District

Servicios A (polygons and lines)
Camellón, Metro Station, Hospitals, Parks, Schools, etc

 (Federal District)


Servicios L (polygons and points)
Bridges, Railways, Tren Metropolitano, Lindero, etc
 (Federal District)


Servicios P (points)
Churches, Schools, Hospitals, etc
 (Federal District)

P.S. You can contact the INEGI and tell them what you think of the way they distribute data.
P.P.S. If you need shapefiles of elevation curves, archeological sites, rivers, etc, try this other script


Don't miss a thing: Follow me @diegovalle on Twitter, grab the RSS feed or subscribe by email

11 comments:

Irving said...

Thanks! On Mac the only thing that you need is to install wget and change the rename command in line 51 by mv (changing sintaxis of curse). Anyway, nice script, very useful!

Diego Valle-Jones said...

I think you can also use 'brew install rename' on OSX

Enrique said...

Diego, the script doesn't work. I think the problem is INEGI..

Diego Valle-Jones said...

Enrique, could you tell what error messages you're getting?

Rodolfo Wilhelmy said...

For mac users, I highly recommend homebrew to get you through the tool setup.

brew install gdal
brew install cmake (to install innoextract http://constexpr.org/innoextract/install#macosx)

and so on

Rodolfo Wilhelmy said...

For anyone looking for a GeoJSON version of the files, you could try this: https://gist.github.com/wilhelmbot/6722511

Carlos Erwin Rodríguez Herández Vela said...

Hi there,

I am using opensuse and cannot download anything, my guess is that INEGI's page has changed, am I correct? what would be the correct location then?

cheers!

Diego Valle-Jones said...

Carlos,

It's working for me now

David Lira said...

Que buena onda de sitio. You have done such a great job by simply uploading the state shapefiles. It is amazing. I cannot express my gratitude. Getting something from INEGI is just tortuous. It is a shame that government agencies do not understand the importance of giving access to people to ALL public information.

Jorge Odenthal said...

Gracias.

Luis Angel Flores said...

Thank you so much for this

Post a Comment

Thank you for your interesting and insightful comments. I truly look forward to reading them.