Skip to content

Instantly share code, notes, and snippets.

View diegovalle's full-sized avatar

Diego Valle-Jones diegovalle

View GitHub Profile
#!/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
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 August 22, 2016 16:33
Download electoral shapefiles from the INE (includes colonias)
#!/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"
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 19:26
Shapefiles from the the Encuesta Intercensal 2015
#! /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 January 18, 2016 04:51
Preliminary shapefiles from the the Encuesta Intercensal 2015
#! /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
@diegovalle
diegovalle / privacy_policy_blogdiegovallenet.md
Last active May 27, 2018 17:02
Privacy policy for blog.diegovalle.net

Privacy Policy

Last revised on 2018-05-18

www.diegovalle.net, blog.diegovalle.net Privacy Policy

This Privacy Policy describes how your personal information is collected, used, and shared when you visit or make a purchase from www.diegovalle.net or blog.diegovalle.net (the “Site”).

PERSONAL INFORMATION WE COLLECT

@diegovalle
diegovalle / election2015.R
Last active August 29, 2015 14:22
2015 Election
library(ggplot2)
library(dplyr)
library(readr)
library(rgeos)
library(maptools)
library(rgdal)
library(scales)
library(downloader)
#Download the latest version of the PREP
@diegovalle
diegovalle / mx_hexgrid.json
Created May 15, 2015 03:51
Hex Grid of Mexican States
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@diegovalle
diegovalle / homicides-2013.Rmd
Last active August 1, 2018 15:38
changes and trends in homicide rates in the most violent metro areas or big municipios or at the national level
---
title: "Changes in homicide rates"
output: html_document
---
I've updated the [mxmortalitydb](https://github.com/diegovalle/mxmortalitydb) package to include 2013 data. This data only packages includes all injury intent deaths (accidents, homicides, suicides and unspcified intent) that were registered in Mexico from 2004 to 2013. You can use the package to calculate changes and trends in homicide rates in the most violent metro areas or big municipios.
```{r}
#if (!require('devtools')) install.packages('devtools')