The giscourse package has four composite high level functions that load in data for a site.
You can either use a string of characters to geocode the site, or the coordinates as latitude and longitude. If a distance in meters is provided the functions download all features within this radius. If no distance is given then the default is to download all the features inside the OS 5km grid square for the site.
library(giscourse)
conn<-connect()
landcover("Arne, Dorset") ->arne_lcover
sssi("Arne, Dorset") ->arne_sssi
phabitat("Arne, Dorset") -> arne_phabitat
osm("Arne, Dorset")->arne_osm
Use burst =TRUE to plot each land use separately. Useful for exploration.
mapviewOptions(legend=FALSE)
mapview(arne_lcover,zcol="bhab",burst=TRUE, hide = TRUE) %>% extras()
library(tmap)
arne_lcover %>% filter(bhab !="Saltwater") %>%
qtm("bhab") + tmap_style("classic") + tmap_options(legend.outside=TRUE) + tm_scale_bar() + tm_compass(type="arrow")
The coordinates are for a study point in the New forest
lon<--1.5
lat<-50.86
landcover(lon,lat,dist=2000) ->nf_lcover
sssi(lon,lat,dist=2000) ->nf_sssi
phabitat(lon,lat,dist=2000) -> nf_phabitat
osm(lon,lat,dist=2000)->nf_osm
mapview(nf_lcover,zcol="bhab",burst=TRUE, hide = TRUE) %>% extras()
nf_lcover %>%
qtm("bhab") + tmap_style("classic") + tmap_options(legend.outside=TRUE) + tm_scale_bar() + tm_compass(type="arrow")
It’s easy to calculate total areas of each habitat.
nf_lcover %>% group_by(bhab) %>% summarise(area_ha=round(sum(area)/10000,1)) -> areas
library(ggplot2)
areas %>% arrange(area_ha) %>% mutate(bhab = factor(bhab, bhab)) %>%
ggplot(aes(x=bhab,y=area_ha,lab=area_ha)) +geom_bar(stat="identity",fill="grey") + geom_label(aes(x = bhab, y = area_ha, label = paste(area_ha,"ha"))) + coord_flip() + theme_bw()
All the layers can be written to a single geodata package file, exported from the server and dropped into a local QGIS project for work offline.
st_write(arne_lcover, dsn="geodata.gpkg", layer="arne_lcover")
st_write(arne_sssi, dsn="geodata.gpkg", layer="arne_sssi")
## Etc ..