Skip to content

Instantly share code, notes, and snippets.

Diego Valle-Jones diegovalle

Block or report user

Report or block diegovalle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@diegovalle
diegovalle / README.md
Last active Jun 18, 2019
Topojson of Mexican municipalities and states
View README.md

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
View download_mapa_digital.sh
#! /bin/bash
# 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 -nc"
# The mapa digital is available as 4 files
declare -a extensions=(".exe" "-1.bin" "-2.bin" "-3.bin")
$WGET "http://internet.contenidos.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/nueva_estruc/promo/Instalador_proy_bas_inf_2017.zip" -O md.zip
@diegovalle
diegovalle / shp_encuesta_intercensal_2015.sh
Last active May 20, 2019
Shapefiles from the the Encuesta Intercensal 2015
View shp_encuesta_intercensal_2015.sh
#! /bin/bash
# Author: Diego Valle-Jones
# Web: https://www.diegovalle.net
# LICENSE: Apache 2.0
# Purpose: Download shapefiles of manzanas (blocks), agebs (census areas), ejes
# viales (streets), interesting areas and a whole bunch of other stuff from
# the Encuesta Intercensal 2015
# As of now, this script has not been tested on Windows,
@diegovalle
diegovalle / download-census-shp.sh
Last active May 20, 2019
Download shapefiles at the census tract and block level for all of urban Mexico—more than 5 GB of data!
View download-census-shp.sh
#!/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
View sinaica_mayo.R
library(aire.zmvm)
library(rsinaica)
library(ggplot2)
library(tidyverse)
library(lubridate)
library(zoo)
library(hrbrthemes)
pm25_2019 <- sinaica_param_data("PM2.5", "2019-05-01", "2019-05-16")
View contingencia_extraordinaria.R
library(aire.zmvm) #devtools::install_github('diegovalle/aire.zmvm')
library(ggplot2)
library(tidyverse)
library(lubridate)
library(zoo)
library(hrbrthemes)
df <- get_station_month_data("HORARIOS", "PM25", 2019, 5)
df <- df %>%
filter(station_code %in% c("SAC", "NEZ")) %>%
View pm25_o3.R
library(lubridate)
library(aire.zmvm)
library(ggplot2)
library(dplyr)
library(hrbrthemes)
get_latest_imeca()
df <- get_zone_imeca("HORARIOS", "TC", "TZ", "2019-05-01", "2019-05-14")
df$datetime <- ymd_h(paste0(df$date, " ", df$hour))
@diegovalle
diegovalle / mx_geofacet.R
Last active May 4, 2019
Mexico geofacet
View mx_geofacet.R
library(dplyr)
library(readr)
library(ggplot2)
library(geofacet)
read_csv("https://data.diegovalle.net/elcrimen/data/nm-estatal-victimas.csv.gz") %>%
filter(subtipo == "HOMICIDIO DOLOSO") %>%
group_by(subtipo, state_code, state, date) %>%
summarise(count = sum(count, na.rm = TRUE),
@diegovalle
diegovalle / key.asc
Last active Feb 22, 2019
PGP PUBLIC KEY - Diego Valle-Jones
View key.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFNoG6gBEADUb3F7iVz7k6yt5oVipTv4F0kg6SUoBEPcU/sSwwu40XLyDRm2
fVOgdsr5lWYTpcq4JWOk7S27IOTknZpWMNetdb3XHHdATWoHSEln3acIvZWQxmQ8
nJFIKfgM4WbWBPQMFXs9KU5FrBJC/iETzlgv7yFfvp1eBfz57fUNAE3ZQ496du9w
VPiXscN7Q49KCz/V/QE59agiokEbLpnVC2q8kjM+ydjSjEUNTvqwJPBek6KQDkHT
rHiEw/JKA+/P3FrDdp2LFtLpKmbgOviqV1+2GtQE16qjA0FfsoA3pK9wJeu21Qtv
vajY+Oe864TFkOJG/fO07RzsTfqA63FfDPtm+s/j18OcISab1DPk6guEmTOTqEsB
RAUMUiMyu7HawCSob6vwYrNsRlU6S/KFnC2AlWOfpBStq1tiEbqo/fGn2I84744o
J6eCyP15qG0NbFt+tF53iEMRVPG+VH40v1nymPbe5xUdcvj6kv/1A46PM0zBmM60
@diegovalle
diegovalle / carto_electoral.sh
Last active Feb 5, 2019
Download electoral cartography from the INE
View carto_electoral.sh
#!/bin/bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Purpose: Script to download electoral shapefiles
# from http://cartografia.ife.org.mx/sige7/?distritacion=federal
set -euo pipefail
# Be sure to update this variable when the INE updates the shapefiles
DATE="13jul2016"
You can’t perform that action at this time.