-mapLatLon.metro <- openproj(map.metro)
-autoplot(mapLatLon.metro) +
- geom_point(data = shape.metro.df, # geom_sf is not yet in ggplot2 on CRAN, so sticking to this for now
+sfg_metro <- st_polygon(list(rbind(c(lon.metro[1],lat.metro[1]),
+ c(lon.metro[2],lat.metro[1]),
+ c(lon.metro[2],lat.metro[2]),
+ c(lon.metro[1],lat.metro[2]),
+ c(lon.metro[1],lat.metro[1])
+ )))
+metroTiles <- get_tiles(st_transform(st_sfc(sfg_metro, crs = 4326), 3857), provider = "Stadia.Stamen.TonerLite", crop = TRUE, zoom = 11)
+# Let's look at secondary school only
+# 95th percentile of school size
+secon95th <- quantile(shape.metro.df[,"totalsecon">0]$totalsecon,probs = .95)
+ggplot() +
+ geom_spatraster_rgb(data = metroTiles) +
+ geom_sf(data = filter(shape.metro.df, totalsecon > 0),
+ aes(color = totalsecon,
+ size = totalsecon),
+ ) +
+ geom_sf_label(data = filter(shape.metro.df, totalsecon > secon95th), # name top 5% schools