Skip to content

Instantly share code, notes, and snippets.

View zross's full-sized avatar

Zev Ross zross

View GitHub Profile
# code to take a PDF and scrape address information. Note that this particular script will
# only work using the specific PDF formatting my PDF had so you can use as a guide but
# it will definitely not work on your PDF!
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import HTMLConverter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
@zross
zross / index.html
Created September 23, 2014 13:58
GeoJSON data on Leaflet Map with MapBox tiles
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css' rel='stylesheet' />
<style>
[{
"id": 1,
"sex_code": 1,
"mortality_death_age": [{
"mortality_death_age_id": 1,
"death_age": "death_age_00",
"death_num": "995"
}, {
"mortality_death_age_id": 2,
"death_age": "death_age_01",
[
{
"name": "Germany",
"series": [
{
"name": "2010",
"value": 7300000
},
{
"name": "2011",
[{
"name": "death_age_95",
"series": [{
"name": "Females",
"value": -6517
}, {
"name": "Males",
"value": 1891
}]
}, {
[{
"results": [{
"name": "death_age_95",
"series": [{
"name": "Females",
"value": 6517
}, {
"name": "Males",
"value": 1891
}]
@zross
zross / scrape_spatial.R
Created April 30, 2019 13:03
For getting download counts for spatial packages
# Grab the list of spatial packages from the R Task View (Bivand)
# and get the count of monthly downloads
library(rvest)
library(dplyr)
spatial_task_view <- read_html("https://cran.r-project.org/web/views/Spatial.html")
res <- spatial_task_view %>%
html_nodes(xpath = "/html/body/ul[1]") %>%
html_children() %>%
@zross
zross / non-gis-y-webmapping.md
Last active February 8, 2019 18:01
Web mapping applications with multiple layers

Suggestions from Twitter for more "elegant" web mapping applications

Specifically I'm looking for web mapping applications that include multiple layers and don't look like an ArcGIS clone -- perhaps something that looks like it was designed by a designer rather than a GIS tech :) This is a list of responses from Twitter, many of which do look GIS-y so more suggestions are welcome...

@zross
zross / hooks.R
Last active November 28, 2018 02:59
Not completely finished hook to add fragment tags to RMarkdown code chunks (slidify, revealjs, R) v2
library(knitr)
opts_chunk$set(collapse=TRUE, echo=TRUE,
error=FALSE, message=FALSE,
warning=FALSE, cache=FALSE)
s0 <- knitr::knit_hooks$get('source')
o0 <- knitr::knit_hooks$get('output')
p0 <- knitr::knit_hooks$get('plot')
knitr::knit_hooks$set(