Last active
August 10, 2016 03:07
-
-
Save benjaminrobinson/58d2368b4399022dc055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
options(stringsAsFactors=FALSE) | |
options(scipen=20) | |
options(digits=15) | |
pkg_test <- function(x){ | |
if(x %in% rownames(installed.packages())){ | |
suppressWarnings(library(x,character.only=TRUE)) | |
return(paste0("Loaded the ",x," Package")) | |
} else { | |
install.packages(x) | |
suppressWarnings(library(x,character.only=TRUE)) | |
return(paste0("Installed and Loaded the ",x," Package")) | |
} | |
} | |
pkg_test("jsonlite") | |
pkg_test("dplyr") | |
pkg_test("rgdal") | |
data <- rbind( | |
fromJSON("http://cagismaps.hamilton-co.org/PropertyActivity/CacheTest/getCachedCluster?nameOfFile=eActCincOpenPMCE_7")$feature$attributes, | |
fromJSON("http://cagisonline.hamilton-co.org/arcgis/rest/services/EACTIVITIES/eActCincOpenPMCE/MapServer/7/query?where=LAST_UPDATED%20%3E%20sysdate%20-%207&outFields=*&returnGeometry=true&f=pjson&orderByFields=LAST_UPDATED%20desc")$features$attributes | |
) | |
geom <- rbind( | |
fromJSON("http://cagismaps.hamilton-co.org/PropertyActivity/CacheTest/getCachedCluster?nameOfFile=eActCincOpenPMCE_7")$feature$geometry %>% select(x,y), | |
fromJSON("http://cagisonline.hamilton-co.org/arcgis/rest/services/EACTIVITIES/eActCincOpenPMCE/MapServer/7/query?where=LAST_UPDATED%20%3E%20sysdate%20-%207&outFields=*&returnGeometry=true&f=pjson&orderByFields=LAST_UPDATED%20desc")$features$geometry %>% select(x,y) | |
) | |
code <- data %>% cbind(geom) %>% | |
mutate(LAST_UPDATED=substr(LAST_UPDATED,1,10) %>% | |
as.numeric %>% | |
as.POSIXct(origin="1970-01-01") %>% | |
as.Date(origin="1970-01-01"),ENTERED_DATE=substr(ENTERED_DATE,1,10) %>% | |
as.numeric %>% | |
as.POSIXct(origin="1970-01-01") %>% | |
as.Date(origin="1970-01-01"), | |
x=as.numeric(x), | |
y=as.numeric(y), | |
STREET_DIRECTION=trimws(STREET_DIRECTION), | |
STREET_NAME=trimws(STREET_NAME), | |
CITY_ID=trimws(CITY_ID) | |
) | |
coordinates(code) <- c('x','y') | |
proj4string(code) <- CRS("+init=epsg:3735") | |
code <- code %>% | |
spTransform(CRS("+init=epsg:4326")) %>% | |
as.data.frame %>% | |
rename(LONGITUDE=x,LATITUDE=y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment