]> git.vanrenterghem.biz Git - www2.vanrenterghem.biz.git/blob - posts/WA_roads_in_R_using_sf.mdwn
Voeg alle posts toe.
[www2.vanrenterghem.biz.git] / posts / WA_roads_in_R_using_sf.mdwn
1 [[!meta date="2017-10-17 20:35:40 +0800"]]
3 [[!tag R spatial analysis visualisation]]
4 How cool is this? A map of Western Australia with all state roads marked in only 5 lines of R!
6 [[!format r """
7 WARoads <- st_read(dsn = "data/", layer = "RoadNetworkMRWA_514", stringsAsFactors = FALSE)
8 WALocalities <- st_read(dsn = "data/", layer = "WA_LOCALITY_POLYGON_shp", stringsAsFactors = FALSE)
9 ggplot(WALocalities) +
10   geom_sf() +
11   geom_sf(data = dplyr::filter(WARoads, network_ty == "State Road"), colour = "red")
12 """]]
14 [[Map of WA state roads|/pics/state-roads.png]]
16 Courtesy of the development version of ggplot2 - geom_sf is not yet available in the version on CRAN.