library(sf)
library(dplyr)
veg <- st_read("data/AnalysisReady/AnalysisReady.gpkg", "vegetation")
head(veg)
# View the different categories within the CWHR Lifeform field
unique(veg$CWHR_LIFEF)
# Filter to get on the areas of conifer
conifer <- filter(veg, CWHR_LIFEF == "WHR_CON")
# Turn these into a single feature with st_union
conifer <- st_union(conifer)
# It can be done this way with piping
conifer <- veg %>%
filter(CWHR_LIFEF == "WHR_CON") %>%
st_union()
# Basic plot
plot(conifer, col = "green")
# We can also union by CWHR lifeform.
# Creating a single feature for each lifeform type.
whr <- veg %>%
# Tell R to treat the data as groups by lifeform
group_by(CWHR_LIFEF) %>%
# summarize on the geom column with st_union to collapse
# each category into its own feature.
summarize(geometry = st_union(geom))
whr
plot(whr)