【R】ggspatial
2020年12月19日
1. はじめに
ggspatial
は、ggplotでspatial data を簡単に扱えるようにしてくれるパッケージです。sf, sp, rasterに対応しています。
2. インストール
CRANからインストールできます。
install.packages("ggspatial")
3. 使ってみる
library(ggplot2) library(ggspatial) load_longlake_data() ggplot() + annotation_map_tile(zoomin = -1) + annotation_spatial(longlake_roadsdf, size = 2, col = "black") + annotation_spatial(longlake_roadsdf, size = 1.6, col = "white") + annotation_spatial(longlake_buildingsdf, size = 2, col = "red") + layer_spatial(longlake_depth_raster, aes(colour = stat(band1))) + scale_fill_viridis_c(na.value = NA) + layer_spatial(longlake_depthdf, aes(fill = DEPTH_M)) + layer_spatial(longlake_streamsdf) + annotation_scale(location = "tl") + annotation_north_arrow(location = "br", which_north = "true")

4. さいごに
簡単にきれいに描画できるなあ。