Skip to content

Instantly share code, notes, and snippets.

View sjsrey's full-sized avatar

Sergio Rey sjsrey

View GitHub Profile
@sjsrey
sjsrey / README.md
Last active December 24, 2015 13:09 — forked from wrobstory/README.md

Choropleth Mapping with Folium

A Leaflet.js map created with Folium and a custom D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_3 = folium.Map(location=[40, -99], zoom_start=4)
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
               columns=['GEO_ID', 'Median_Household_Income_2011'],
               key_on='feature.id',
 fill_color='PuRd', line_opacity=0.3,
@sjsrey
sjsrey / README.md
Last active December 27, 2015 01:19
Folium and PySAL

Folium and PySAL

This gist demonstrates the combined use of the Python Spatial Analysis Library PySAL together with Folium.

Author: Serge Rey

What is demonstrated

# -*- mode: ruby -*-
# vi: set ft=ruby :
MACHINE_NAME = "PYVM"
Vagrant.configure("2") do |config|
#config.vm.box = "1404amd64"
config.vm.box = "base"
# config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
@sjsrey
sjsrey / gitlogger.rb
Last active August 29, 2015 14:10 — forked from ttscoff/gitlogger.rb
#!/usr/bin/env ruby
require 'time'
require 'erb'
require 'cgi'
filename = "~/.gitlogger"
## File format, One per line
# Repo Name:/path/to/base
dayone = false # log to day one? (true or false)
textlog = false # "~/Dropbox/nvALT2.2/GitLogger.md" # set to false to disable
@sjsrey
sjsrey / airports.csv
Last active August 29, 2015 14:23
Exploring PySAL arc based KDTrees for nearest neighbor weights #646
airport_id name city country iata_faa iaco latitude longitude altitude zone dst
1 Goroka Goroka Papua New Guinea GKA AYGA -6.081689 145.391881 5282 10 U
2 Madang Madang Papua New Guinea MAG AYMD -5.207083 145.7887 20 10 U
3 Mount Hagen Mount Hagen Papua New Guinea HGU AYMH -5.826789 144.295861 5388 10 U
4 Nadzab Nadzab Papua New Guinea LAE AYNZ -6.569828 146.726242 239 10 U
5 Port Moresby Jacksons Intl Port Moresby Papua New Guinea POM AYPY -9.443383 147.22005 146 10 U
6 Wewak Intl Wewak Papua New Guinea WWK AYWK -3.583828 143.669186 19 10 U
7 Narsarsuaq Narssarssuaq Greenland UAK BGBW 61.160517 -45.425978 112 -3 E
8 Nuuk Godthaab Greenland GOH BGGH 64.190922 -51.678064 283 -3 E
9 Sondre Stromfjord Sondrestrom Greenland SFJ BGSF 67.016969 -50.689325 165 -3 E
@sjsrey
sjsrey / airports.ipynb
Last active August 29, 2015 14:23
Exploring PySAL arc based KDTrees for nearest neighbor weights
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sjsrey
sjsrey / getbibs.py
Created January 11, 2017 22:59 — forked from wcaleb/getbibs.py
The Pandoc filter and shell script I use to make a bibliography file from my BibTeX note files. See http://wcm1.web.rice.edu/plain-text-citations.html
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Pandoc filter that grabs the BibTeX code block from each note file
# and then uses bibtexparser to add a "short title" entry in the "note" field,
# appending finished BibTeX entry to a bibliography file.
from pandocfilters import toJSONFilter, CodeBlock
# https://github.com/sciunto/python-bibtexparser
import bibtexparser
@sjsrey
sjsrey / joy.ipynb
Last active October 30, 2017 00:13
Exploring joy plots for use in regional income inequality dynamics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sjsrey
sjsrey / reprex.r
Last active September 1, 2017 00:59
Using reticulate to test pysal against spdep
library(reticulate)
use_condaenv("pysal2")
pysal <- import("pysal")
np <- import("numpy")
pth <- pysal$examples$get_path("stl_hom.txt")
f <- pysal$open(pth)
col <- f$by_col("HR8893")
y <- np$array(col)
w <- pysal$open(pysal$examples$get_path("stl.gal"))$read()
mi <- pysal$Moran(y, w, two_tailed=FALSE)