Skip to content

Instantly share code, notes, and snippets.

View pattyf's full-sized avatar

Patty Frontiera pattyf

View GitHub Profile
#
# get_fips_from_fcc.R
#
## After: https://gist.githubusercontent.com/ramhiser/f09a71d96a4dec80994c/raw/d3e1d9fc1e7f38b2a402eee3237221fa9a47d1da/latlong2fips.r
# -----------------------------------------------------------------------------------------------------------------------
# Define function to fetch Block FIPS from
# FCC's Census Block Conversions API
## For example, test in browser:
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
@pattyf
pattyf / index.html
Created December 9, 2016 22:22
RMarkdown Example Leaflet Map
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="data:application/x-javascript,%28function%28%29%20%7B%0A%20%20%2F%2F%20If%20window%2EHTMLWidgets%20is%20already%20defined%2C%20then%20use%20it%3B%20otherwise%20create%20a%0A%20%20%2F%2F%20new%20object%2E%20This%20allows%20preceding%20code%20to%20set%20options%20that%20affect%20the%0A%20%20%2F%2F%20initialization%20process%20%28though%20none%20currently%20exist%29%2E%0A%20%20window%2EHTMLWidgets%20%3D%20window%2EHTMLWidgets%20%7C%7C%20%7B%7D%3B%0A%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20a%20viewer%20pane%2E%20If%20not%2C%20we%27re%20in%20a%20web%20browser%2E%0A%20%20var%20viewerMode%20%3D%20window%2EHTMLWidgets%2EviewerMode%20%3D%0A%20%20%20%20%20%20%2F%5Cbviewer%5Fpane%3D1%5Cb%2F%2Etest%28window%2Elocation%29%3B%0A%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20Shiny%20mode%2E%20If%20not%2C%20it%27s%20a%20static%20document%2E%0A%20%20%2F%2F%20Note%20that%20static%20widgets%20can%20appear%20in%20both%20Shiny%20and%20static%2
@pattyf
pattyf / index.html
Last active October 3, 2016 00:13
Map of Percent of Individuals below Poverty Level by SF Neighborhood (ACS 2010-14)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="data:application/x-javascript,%28function%28%29%20%7B%0A%20%20%2F%2F%20If%20window%2EHTMLWidgets%20is%20already%20defined%2C%20then%20use%20it%3B%20otherwise%20create%20a%0A%20%20%2F%2F%20new%20object%2E%20This%20allows%20preceding%20code%20to%20set%20options%20that%20affect%20the%0A%20%20%2F%2F%20initialization%20process%20%28though%20none%20currently%20exist%29%2E%0A%20%20window%2EHTMLWidgets%20%3D%20window%2EHTMLWidgets%20%7C%7C%20%7B%7D%3B%0A%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20a%20viewer%20pane%2E%20If%20not%2C%20we%27re%20in%20a%20web%20browser%2E%0A%20%20var%20viewerMode%20%3D%20window%2EHTMLWidgets%2EviewerMode%20%3D%0A%20%20%20%20%20%20%2F%5Cbviewer%5Fpane%3D1%5Cb%2F%2Etest%28window%2Elocation%29%3B%0A%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20Shiny%20mode%2E%20If%20not%2C%20it%27s%20a%20static%20document%2E%0A%20%20%2F%2F%20Note%20that%20static%20widgets%20can%20appear%20in%20both%20Shiny%20and%20static%2
@pattyf
pattyf / index.html
Created August 19, 2016 20:51
campus odyssey.js storymap
<!doctype><html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Odyssey.js Slides</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="http://cartodb.github.io/odyssey.js/sandbox/favicon.png">
<link rel="icon" type="image/png" href="http://cartodb.github.io/odyssey.js/sandbox/favicon.png">
@pattyf
pattyf / address_input_for_census_api.csv
Created April 17, 2015 17:48
Format for input address for census geocoding api
1 4728 SCOTIA AVE Oakland CA 94605
2 10709 COTTER ST Oakland 94605
3 10834 GOLF LINKS RD Oakland CA 94605
4 4627 GRASS VALLEY RD Oakland CA 94605
5 380 ELYSIAN FIELDS DR Oakland CA 94605
6 111 DONNA WAY CA 94605
7 4855 SCOTIA AVE Oakland CA 94605
8 248 ELYSIAN FIELDS DR Oakland CA 94605
9 10520 PEBBLE BEACH DR Oakland CA 94605
@pattyf
pattyf / getFipsForPoints.R
Last active October 1, 2015 20:24
spatial intersection of points with census data to extract FIPS codes
## ############################################################################
#
# Joining Census FIPS codes to points via point in polygon overlay
#
# Author: Patty Frontiera pfrontiera@berkeley.edu
# Date: 2014_04_15
# Last updated: 2014_04_17
#
# Purpose:
## This script takes as input a point file and a file of Census Tiger data
@pattyf
pattyf / test_address_points.csv
Last active August 29, 2015 14:19
Point data - geococed addresses in text file
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4 in line 1.
inaddress|street_address|street_name|latitude|country_code|fips_county|country_name|country_code3|longitude|region|locality|street_number|confidence|
1026 PALISADE ST,Hayward,CA,94542|1026 Palisade St|Palisade St|37.663033|US|06001|United States|USA|-122.072113|CA|Hayward|1026|1.0|
22718 RANCHO PALOMARES PL,Castro Valley,CA,94552|22718 Rancho Palomares Pl|Rancho Palomares Pl|37.691798|US|06001|United States|USA|-122.041088|CA|Castro Valley|22718|1.0|
49000 MILMONT DR,Fremont,CA,94538|49000 Milmont Dr|Milmont Dr|37.460202|US|06001|United States|USA|-121.921341|CA|Fremont|49000|1.0|
768 SYCAMORE AVE,Hayward,CA,94544|768 Sycamore Ave|Sycamore Ave|37.66263|US|06001|United States|USA|-122.078167|CA|Hayward|768|0.878|
7546 LANGMUIR CT,Dublin,CA,94568|7546 Langmuir Ct|Langmuir Ct|37.718845|US|06001|United States|USA|-121.921277|CA|Dublin|7546|1.0|
10880 ETTRICK ST,Oakland,CA,94605|10880 Ettrick St|Ettrick St|37.75126|US|06001|United States|USA|-122.130462|CA|Oakland|10880|0.878|
1645 WELFORD CIR,Hayward,CA,94544|159
@pattyf
pattyf / geocode_withFips_censusAPI
Last active August 29, 2015 14:17
command line geocoding with census api fetching FIPS at same time
# Command for processing file of addresses using CENSUS geocoder.
# Addresses should be in the following format (comma separated address components, no header row, one address per line):
# 1,10709 COTTER ST,Oakland,CA,94605
# 2,4728 SCOTIA AVE,Oakland,CA,94605
# 3,10834 GOLF LINKS RD,Oakland,CA,94605
curl --form addressFile=@address_input_for_census_api.csv --form benchmark=Public_AR_Census2010 --form vintage=Census2010_Census2010 http://geocoding.geo.census.gov/geocoder/geographies/addressbatch
#
# Note that the output geographic coords will be in one column of the csv file, eg "-122.001,37.666".
# If available in Excel, you can split these into two columns by using the Data > Text to Columns function.
# You can also use the excel functions left, right, len and find to split the values on the comma, for example: