This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# publiclibraries.com scraper | |
import BeautifulSoup | |
import urllib2 | |
l = [("http://www.publiclibraries.com/alabama.htm","AL"), | |
("http://www.publiclibraries.com/alaska.htm","AK"), | |
("http://www.publiclibraries.com/arizona.htm","AZ"), | |
("http://www.publiclibraries.com/arkansas.htm","AR"), | |
("http://www.publiclibraries.com/california.htm","CA"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#script that attempts to match compare lat,long points two csv files, match by distance | |
#justin grimes (@justgrimes) 04/16/12 | |
import math | |
import csv | |
import sys | |
import re | |
# takes two lat/long points and returns distance, modified code from -> http://www.johndcook.com/python_longitude_latitude.html | |
def distance_on_unit_sphere(lat1, long1, lat2, long2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT latitude,longitude, (3963.191 * ACOS( | |
(SIN(PI()* 40.7383040 /180)*SIN(PI()*latitude/180)) + | |
(COS(PI()* 40.7383040 /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* -73.99319 /180)) | |
)) AS distance | |
FROM TABLE | |
WHERE 1=1 | |
AND 3963.191 * ACOS( (SIN(PI()* 40.7383040 /180)*SIN(PI() * latitude/180)) + | |
(COS(PI()* 40.7383040 /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* -73.99319 /180)) | |
) <= 1.5 | |
ORDER BY 3963.191 * ACOS( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(tm) | |
a <- Corpus(DirSource("C:/Users/jgrimes/Desktop/text/"), readerControl = list(language="lat")) | |
#summary(a) | |
a <- tm_map(a, function(x) iconv(enc2utf8(x), sub = "byte")) | |
a <- tm_map(a, removePunctuation) | |
a <- tm_map(a, removeNumbers) | |
a <- tm_map(a, stripWhitespace) | |
a <- tm_map(a, tolower) | |
a <- tm_map(a, removeWords, stopwords("english")) | |
a <- tm_map(a, stemDocument, language = "english") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load packages | |
library(maps) # To draw map | |
library(maptools) | |
# download data files from IMLS website | |
temp <- tempfile() | |
download.file("http://www.imls.gov/assets/1/AssetManager/pupld11b_csv.zip",temp) | |
pupld11b <- read.csv(unz(temp, "pupld11b.csv")) #file with library systems (admin buildings) | |
puout11b <- read.csv(unz(temp, "puout11b.csv")) #file with library outlets (all buildings) | |
unlink(temp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SDC Annual Meeting 2014 Introduction to R, R Studio, and Statistical Computing | |
# Load downloaded data from PLS 2012 survey, CSV format (comma seperated value) | |
pupld12a_csv <- read.csv("pupld12a_csv/pupld12a.csv", header = TRUE, sep=",", quote = "\"") | |
puout12a_csv <- read.csv("pupld12a_csv/puout12a.csv", header = TRUE, sep=",", quote = "\"") | |
pusum12a_csv <- read.csv("pupld12a_csv/pusum12a.csv", header = TRUE, sep=",", quote = "\"") | |
# Load downloaded data from PLS 2012 survey, Excel format (xls) | |
#install.packages("gdata") | |
library(gdata) #library to load xls data; if loading xlsx files use XLConnect library |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to load public public library data from the most recent | |
# FY 2012 Public Library Survey (PLS) from Institute of Museum and Library Services | |
# Data documentation -> http://www.imls.gov/assets/1/AssetManager/fy2012_pls_data_file_documentation.pdf | |
# More info about data & survey -> http://www.imls.gov/research/public_libraries_in_the_united_states_survey.aspx | |
install.packages("audiolyzR") | |
library("audiolyzR") | |
# Load PLS 2012 directly from the web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to load public public library data from FY 2012 Public Library Survey (PLS) from Institute of Museum and Library Services | |
# and merge it with most recent broadband data from National Broadband Map Community Anchor Institution data | |
# | |
# FOR REFERENCE | |
# CAIID - Unique federal ID's associated with the CAICAT | |
# CAICAT -these are the unique federal ID's associated with the CAICAT | |
# MAXADDOWN - Maximum Advertised Download Speed subscribed to at this CAI | |
# MAXADUP - Maximum Advertised Upload Speed subscribed to at this CAI | |
# BBSERVICE - Does institution subscribe to broadband service at location (ex. Y=Yes; N=No; U=Unknown), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PLS Dot Density Map | |
library(maps) | |
library(mapproj) | |
library(maptools) | |
library(geosphere) | |
library(splancs) | |
library(foreign) | |
# Map just the points |
OlderNewer