Skip to content

Instantly share code, notes, and snippets.

View diegovalle's full-sized avatar

Diego Valle-Jones diegovalle

View GitHub Profile
@diegovalle
diegovalle / CreateRoutes.R
Created April 13, 2011 03:09
Decode polylines obtained from Google Maps
library(maptools)
library(maps)
library(mapdata)
library(rjson)
library(stringr)
library(RCurl)
library(ggplot2)
GetDirections <- function(from, to) {
@diegovalle
diegovalle / mochomo-jalisco.R
Last active October 5, 2015 15:58
The capture of 'El Mochomo' and homicides in Jalisco
########################################################
# Author: Diego Valle-Jones
# Website: www.diegovalle.net
# Date Created: Tue May 29 17:03:32 2012
# Email: diegovalle at gmail.com
# Purpose: The capture of 'El Mochomo' increased homicides in Jalisco contrary
# to statements by the Mexican government
# Copyright (c) Diego Valle-Jones. All rights reserved
##homicide data for Jalisco
@diegovalle
diegovalle / README.md
Last active January 8, 2024 19:24
Topojson of Mexican municipalities and states

How to create the topojson map:

curl -o estados.zip http://mapserver.inegi.org.mx/MGN/mge2010v5_0.zip
curl -o  municipios.zip http://mapserver.inegi.org.mx/MGN/mgm2010v5_0.zip
unzip estados.zip 
unzip municipios.zip
ogr2ogr states.shp Entidades_2010_5.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
ogr2ogr municipalities.shp Municipios_2010_5.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
topojson -o mx_tj.json -s 1e-7 -q 1e5 states.shp municipalities.shp -p state_code=+CVE_ENT,state_name=NOM_ENT,mun_code=+CVE_MUN,mun_name=NOM_MUN
@diegovalle
diegovalle / README.md
Last active December 14, 2015 21:58
Cartograma No Contiguo de Averiguaciones Previas por Homicidio
@diegovalle
diegovalle / .block
Last active August 2, 2017 16:47
Density map of homicides in Monterrey
license: mit
@diegovalle
diegovalle / download-census-shp.sh
Last active May 20, 2019 19:20
Download shapefiles at the census tract and block level for all of urban Mexico—more than 5 GB of data!
#!/bin/bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Purpose: Download shapefiles of manzanas (blocks), agebs (census areas), ejes
# viales (streets), interesting areas and a whole bunch of other stuff
# 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
@diegovalle
diegovalle / download-mapa-digital.sh
Last active June 11, 2020 00:36
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
@diegovalle
diegovalle / mapa_digital_5.0.A.sh
Last active December 29, 2015 14:39
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
@diegovalle
diegovalle / change-report.Rmd
Last active December 31, 2015 14:09
Changes in homicide rates
Changes in homicide rates
========================================================
Look, another example of using the [mxmortalitydb](https://github.com/diegovalle/mxmortalitydb) package! Changes and trend in homicide rates in the most violent metro areas or big municipios (note the log scales). For comparison the homicide rate in Chicago (metro area) was 8.2
```{r}
library(mxmortalitydb)
library(stringr)
library(plyr)
library(ggplot2)
@diegovalle
diegovalle / contador_bici.R
Last active January 4, 2016 13:09
Datos del contador ciclista ubicado en Reforma 222
## Datos del contador ciclista ubicado en Reforma 222. El contador
## sólo opera en dirección Centro
## Author: Diego Valle
## Web: www.diegovalle.net
library(ggplot2)
library(lubridate)
library(stringr)
library(mgcv)
library(rCharts)