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
View temp_cdmx.R
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html
library(viridis)
library(ggridges)
#devtools::install_github('diegovalle/aire.zmvm')
library(aire.zmvm)
library(lubridate)
library(ggplot2)
library(dplyr)
library(tidyr)
@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 / mx_grid.R
Created Jun 30, 2017
mexico geofacet
View mx_grid.R
library(dplyr)
library(stringr)
library(readr)
library(ggplot2)
library(geofacet)
options(stringsAsFactors = FALSE)
mx_grid <- data.frame(
code = c(2L, 8L, 26L, 3L, 5L, 10L, 19L, 25L, 28L, 1L, 18L, 24L, 32L,
11L, 13L, 14L, 22L, 30L, 6L, 15L, 29L, 9L, 17L, 21L, 31L, 4L,
@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"
View secciones_edomex.sh
#!/bin/bash
#From http://dorganizacion.ieem.org.mx/SIGE/#
mkdir kml
for i in {1..45}
do
curl -Lo kml/seccion_$i.kml "https://www.google.com/fusiontables/exporttable?query=select+col27+from+1DDGrYAoLQ6dTDRz0sUDP3RLxIk8AfI45syz7kxrT+where+col12+%3D+$i&o=kml&g=col27&styleId=2&templateId=2"
done
View leaflet_municipios.R
library("dplyr")
library("mxmaps")
library("geojsonio")
library("jsonlite")
library("leaflet")
# Convert the topoJSON to spatial object
tmpdir <- tempdir()
# have to use RJSONIO or else the topojson isn't valid
write(RJSONIO::toJSON(mxmunicipio.topoJSON), file.path(tmpdir, "mun.topojson"))
@diegovalle
diegovalle / download.sh
Last active Aug 22, 2016
Download electoral shapefiles from the INE (includes colonias)
View download.sh
#!/bin/bash
set -e
# Download electoral shapefiles from the INE
# includes colonias
# needs sudo apt-get install p7zip-rar p7zip-all
# Download the maps
# State abbreviations
declare -a states=("ags" "bc" "bcs" "camp" "coah" "col" "chis" "chih"
"df" "dgo" "gto" "gro" "hgo" "jal" "mex" "mich" "mor" "nay" "nl" "oax"
View mxstates.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / download15.sh
Last active Jan 18, 2016
Preliminary shapefiles from the the Encuesta Intercensal 2015
View download15.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 from
# the Encuesta Intercensal 2015
# As of now, this script has not been tested on Windows and Mac
# systems, only on Ubuntu. The script will create a directory
You can’t perform that action at this time.