# 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(viridis)
# Read the shapefile obtained from WA opendata (SLIP)
-shape <- readOGR(dsn = "data/", layer = "CurrentActiveSchoolsSemester12017_PublicDET_014")
-# Suppress warning about no method existing for SpatialPointsDataframe - TODO use library sf
-shape.df <- suppressWarnings(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)
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),