]> git.vanrenterghem.biz Git - www2.vanrenterghem.biz.git/blob - source/posts/WA_roads_in_R_using_sf.org
Gebruik source folder.
[www2.vanrenterghem.biz.git] / source / posts / WA_roads_in_R_using_sf.org
1 #+date 2017-10-17 20:35:40 +0800
2 #+title WA roads in R using SF
3 #+filetags: R spatial analysis visualisation
5 How cool is this? A map of Western Australia with all state roads marked in only 5 lines of R!
7 #+BEGIN_SRC R
8 WARoads <- st_read(dsn = "data/", layer = "RoadNetworkMRWA_514", stringsAsFactors = FALSE) 
9 WALocalities <- st_read(dsn = "data/", layer = "WA_LOCALITY_POLYGON_shp", stringsAsFactors = FALSE) 
10 ggplot(WALocalities) + geom_sf() +
11 geom_sf(data = dplyr::filter(WARoads, network_ty == "State Road"),
12 colour = "red")
13 #+END_SRC
15 #+caption: Map of WA state roads
16 #+ATTR_HTML: :class img-fluid :alt Map of WA state roads
17 [[file:../assets/state-roads.png]]
19 Courtesy of the development version of ggplot2 - geom_sf is not yet
20 available in the version on CRAN.