Skip to content

Instantly share code, notes, and snippets.

View jdickinson202's full-sized avatar

jdickinson202

View GitHub Profile
@urschrei
urschrei / shapefile.py
Last active September 29, 2021 08:24
Open a shapefile using Fiona, and plot its features using Matplotlib and Descartes
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from descartes import PolygonPatch
import fiona
from shapely.geometry import Polygon, MultiPolygon, shape
# We can extract the London Borough boundaries by filtering on the AREA_CODE key
mp = MultiPolygon(
[shape(pol['geometry']) for pol in fiona.open('data/boroughs/boroughs.shp')
if pol['properties']['AREA_CODE'] == 'LBO'])
@urschrei
urschrei / basemap_descartes.py
Last active November 6, 2020 02:49
How to plot Shapely Points using Matplotlib, Basemap, and Descartes
"""
required packages:
numpy
matplotlib
basemap: http://matplotlib.org/basemap/users/installing.html
shapely: https://pypi.python.org/pypi/Shapely
descartes: https://pypi.python.org/pypi/descartes
random
anonymous
anonymous / gist:2760470
Created May 21, 2012 03:45
Two ways of doing genetic matching in R
# Two Matching Methods
# Method 1 - GenMatch()
library(Matching)
covars <- c("sick", "age", "literate", "employment", "public", "urban", "poverty", "owndwell")
X <- as.matrix(collapsed.data[,covars])
W <- collapsed.data$treated_any
g.weights <- GenMatch(Tr=W, X=X, BalanceMatrix=X, estimand="ATT", M=1,print.level=0,max.generations=1,hard.generation.limit=TRUE)
g.weights$matches
@bradmontgomery
bradmontgomery / ShortIntroToScraping.rst
Created February 21, 2012 02:00
Really short intro to scraping with Beautiful Soup and Requests