X-Git-Url: http://git.vanrenterghem.biz/R/project-wa-schools.git/blobdiff_plain/f27fc3a28ef7ba08696e0075191311dfccfca458..d4ee26d74a52d4d5b4d5f0e933dbcd3ba178978a:/WA_active_schools.R diff --git a/WA_active_schools.R b/WA_active_schools.R index 7792496..da884f9 100644 --- a/WA_active_schools.R +++ b/WA_active_schools.R @@ -1,17 +1,19 @@ # install libgdal-dev on debian first -#install.packages("rgdal") -library(rgdal) +# install libudunits2-dev on debian first +#install.packages("sf") +library(sf) library(tidyverse) +library(broom) #install.packages("OpenStreetMap") library(OpenStreetMap) library(viridis) # Read the shapefile obtained from WA opendata (SLIP) -shape <- readOGR(dsn = "data/", layer = "CurrentActiveSchoolsSemester12017_PublicDET_014") -shape.df <- tidy(shape) -shape.df$latitude <- as.numeric(as.character(shape.df$latitude)) -shape.df$longitude <- as.numeric(as.character(shape.df$longitude)) -shape.df$totalschoo <- as.numeric(as.character(shape.df$totalschoo)) +#shape <- readOGR(dsn = "data/", layer = "CurrentActiveSchoolsSemester12017_PublicDET_014") +shape.df <- st_read(dsn = "data/", layer = "CurrentActiveSchoolsSemester12017_PublicDET_014", stringsAsFactors = FALSE) +shape.df$latitude <- as.numeric(shape.df$latitude) +shape.df$longitude <- as.numeric(shape.df$longitude) +shape.df$totalschoo <- as.numeric(shape.df$totalschoo) # filter out remote islands shape.df <- filter(shape.df,longitude > 100) @@ -63,7 +65,7 @@ shape.metro.df <- filter(shape.df, abs(latitude) <= max(abs(lat.metro)), abs(longitude) >= min(abs(lon.metro))) mapLatLon.metro <- openproj(map.metro) autoplot(mapLatLon.metro) + - geom_point(data = shape.metro.df, + geom_point(data = shape.metro.df, # geom_sf is not yet in ggplot2 on CRAN, so sticking to this for now aes(x = longitude, y = latitude, color = totalschoo),