knitr::opts_chunk$set(fig.width = 8.83, message = FALSE, warning = FALSE)

mapview can be used in piped expressions using %>%, most likely at the very end of it...

Here are just a few examples of piped workflows:

plotting feature unions

library(mapview)
library(poorman)
library(leaflet)
library(sf)
franconia %>%
  st_union %>%
  plot


mapviewing feature unions

franconia %>%
  st_union %>%
  mapview


union by district

franconia %>%
  group_by(district) %>%
  summarize %>%
  mapview(zcol = "district")


districts by area

franconia %>%
  group_by(district) %>%
  summarize %>%
  mutate(area = as.numeric(st_area(.) / 1e6)) %>%
  mapview(zcol = "area")


counties by area

franconia %>%
  mutate(area = as.numeric(st_area(.))) %>%
  mapview(zcol = "area", legend = TRUE)


breweries colored by district

breweries %>%
  st_intersection(franconia) %>%
  mapview(zcol = "district")


number of breweries by county

franconia %>%
  mutate(count = lengths(st_contains(., breweries))) %>%
  mapview(zcol = "count")


brewery density by county

franconia %>%
  mutate(count = lengths(st_contains(., breweries)),
         density = count / as.numeric(st_area(.))) %>%
  mapview(zcol = "density")




r-spatial/mapview documentation built on Dec. 21, 2024, 12:14 a.m.