Updated / printed: 2023-10-25
To try and represent the spatial confidence of the assessment results the following methods attempt to make a fair comparison of the spatial coverage of monitoring data. The methods below aim to give a clearer understanding of how well each broad scale habitat is ‘monitored’ within each CP2 Region for UKMS reporting.
The method for confidence of spatial representativity is discussed in the QSR assessment
Spatial representativity of the data is considered by estimating the percentage of area covered by the benthic monitoring program (a sample considered representative for approximately an area of the size of one c-square) compared to the total surface of a certain BHT x AU to be assessed
— OSPAR CEMP guidelines
With the level of reduction of confidence from reduced representativity of spatial distribution given as (QSR - Table 1):
Quality coding of the data subsets and amongst others spatial representativity (according to OSPAR Guidance document QSR2023) determines the level of confidence of the assessment results based on limited data availability.
— OSPAR CEMP guidelines
There is some further discussion in section 4.4 Spatial Analysis and / or trend analysis, although this mostly discusses the investigation of sample clusters for any local patterns of change or local quality status. However, there is currently no defined methods on how samples should be calculated as representative of area in the CSEMP guidelines, assessments of representation were limited to descriptions for the Greater North Sea assessment (Wijnhoven et. al., 2023).
Spatial representativity should be considered as well, it is for the time being restricted to a description in the main text of the document.
— OSPAR CEMP guidelines
Potential methods to estimate the coverage of samples are explored below, however the script will not include any reduction in confidence of the assessment results due to spatial representativity.
Two methods were tested:
Load pre-processed BH2b spatial layers
### load in pre processed UKMS area
ukms_cs = readRDS("Data/Processed/Spatial/C20230831_ukms_cs")
# transform to ETRS89
ukms_cs_LAEA <- st_transform(ukms_cs, 3035)
# Load processed land area data
land_cs = readRDS("Data/Processed/Spatial/C20230831_land_cs")
# transform to ETRS89
land_cs_LAEA <- st_transform(land_cs, 3035)
# load in CP2 layer
cp2_regions <- st_read("Data/Raw/CP2_Regions/C071222_CP2_reporting_regions.shp")
# select the regions needed
cp2 <- cp2_regions %>%
filter(Region == "Atlantic North-West Approaches, Rockall Trough and Faroe-Shetland Channel" |
Region == "Scottish Continental Shelf"|
Region == "Minches & Western Scotland"|
Region == "Irish Sea"|
Region == "Western Channel & Celtic Sea") %>%
mutate(Region = if_else(Region == "Atlantic North-West Approaches, Rockall Trough and Faroe-Shetland Channel",
as.character("Atlantic North-West Approaches,\nRockall Trough and Faroe-Shetland Channel"), as.character(Region)))
# Select the fields needed
cp2 <- cp2 %>%
select(Region, RegionID)
# transform to ETRS89
cp2 <- st_transform(cp2, 3035)
# Sample data
samples_SAR_rel <- readRDS("Data/Processed/R_data/C20230907_samples_SAR_rel")
# transform points to ETRS89
samples_SAR_rel_LAEA <- st_transform(samples_SAR_rel, 3035)
Create a test area to trial the spatial analysis method and give examples.
# create a test area box for trialing analysis
# enter xmin, ymin, xmax, and ymax coordinates
area_coords <- array(c(-5.5, 53, -3, 54))
# convert coords into a matrix
test_area <- cbind(c(area_coords[1], area_coords[3], area_coords[3], area_coords[1], area_coords[1]),
c(area_coords[2], area_coords[2], area_coords[4], area_coords[4], area_coords[2]))
# convert matrix of coords into a polygon
test_area <- st_polygon(list(test_area))
# set CRS to WG84
test_area <- st_sfc(test_area, crs = 4326)
# convert to ETRS89
test_area <- st_transform(test_area, 3035)
# tidy up
rm(area_coords)
Crop data layers to the test area
# crop land mass
land_test <- st_intersection(land_cs_LAEA, test_area)
# crop CP2
cp2_test <- st_intersection(cp2, test_area)
# crop sample points
samples_test <- st_intersection(samples_SAR_rel_LAEA, test_area)
Load in the test area of the habitat map
# define the area of map to load
bbox_test_area <- st_as_text(st_geometry(test_area))
# load in habitat map in test area
habitat_test <- st_read("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg", layer = "C20230725_CS_cp2_bht_LAEA_GF", wkt_filter = bbox_test_area)
# crop to tests area
habitat_test <- st_intersection(habitat_test, test_area)
Remove transitional waterbody areas from the habitat map
# Load in the transitional waterbodies
EA_trans <- st_read("Data/Processed/Spatial/C20230712_EA_WFD_Transitional_Updated.shp")
SEPA_trans <- st_read("Data/Raw/Transitional_waters/C20230712_SEPA_Transitional_waters.shp")
NIEA_trans <- st_read("Data/Processed/Spatial/C20230712_NIEA_Estuaries.shp")
NRW_trans <- st_read("Data/Raw/Transitional_waters/C20230712_NRW_Transitional_Waterbodies_Cycle_3.shp")
# fix geometry in NIEA layer
NIEA_trans <- st_make_valid(NIEA_trans)
# Combine layers by union
transitional_waters <- st_union(EA_trans, SEPA_trans)
# combine
transitional_waters <- st_union(transitional_waters, NIEA_trans)
# combine
transitional_waters <- st_union(transitional_waters, NRW_trans)
# disolve into a single feature
trans_waters <- st_union(transitional_waters)
rm(transitional_waters)
Remove areas of transitional waters from the habitat map
# transform transitional waters to ETRS89
trans_waters_LAEA <- st_transform(trans_waters, 3035)
# crop transitional waters to the test area
trans_waters_test <- st_intersection(trans_waters_LAEA, test_area)
# remove transitional waters from habitat map area
habitat_test <- st_difference(habitat_test, trans_waters_test)
plot the test data
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = habitat_test, aes(fill = msfd), colour = NA) +
geom_sf(data = samples_test, colour = "red", size = 0.5) +
geom_sf(data = test_area, fill = "transparent", color = "green") +
scale_fill_viridis_d(direction = -1) +
theme_bw() +
theme(legend.position = "none") +
ggtitle("Habitat and sample data in test area")
Calculate habitat coverage (in the test area)
# recalculate feature areas following processing
test_bht_area <- habitat_test %>%
mutate(area_km2 = as.double(area_sf/1000000)) %>%
as.data.frame() %>%
group_by(region, msfd) %>%
summarise(total_km2 = sum(area_km2))
test_bht_area %>%
ungroup() %>%
select(msfd, total_km2) %>%
mutate(total_km2 = round(total_km2, 1)) %>%
datatable(
caption = "Total habitat area in test example",
colnames = c("Broad-scale habitat" = "msfd"),
extensions = 'Buttons',
options = list(pageLength = 15,
dom = 'Brti',
columnDefs = list(list(className = 'dt-center', targets = 1))),
class = "cell-border",
rownames = FALSE)
Building on the recommendations of coverage by c-square described in the OSPAR CEMP guidelines, this method will use the total habitat area and the number of c-squares where samples have been collected.
# Load in c-square grid
csquare_grid <- st_read("Data/Raw/VMS/C20230707_Grid.shp")
# transform to ETRS89
csquare_grid_LAEA <- st_transform(csquare_grid, 3035)
# Reduce the c-squares to those within the limits of the test area
csquare_grid_test <- st_intersection(csquare_grid_LAEA, test_area)
# add unique row id to the grid cells
csquare_grid_test <- csquare_grid_test %>%
dplyr::mutate(Id = row_number())
# join samples to the grid
samples_csquares <- st_join(samples_test, csquare_grid_test) %>%
mutate(year_cat = if_else(sampleyear <2016, "2009-2015", "2016-2021")) %>%
select(sampleref, sampleyear, msfd, Region, year_cat, D_rel, Id)
Id has been assigned to each sample# check all samples are assigned a c-square id
samples_csquares %>%
as.data.frame() %>%
filter(is.na(Id))
# make a temporary selection of the test data
temp <- samples_csquares %>%
as.data.frame() %>%
filter(msfd == "Infralittoral sand", sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id)
# take the bbox limits of the sample data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Infralittoral sand"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Infralittoral sand"), fill = "gold3", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = filter(csquare_grid_test, Id %in% temp$Id), fill = "green", alpha = 0.1) +
geom_sf(data = filter(samples_test, msfd == "Infralittoral sand", sampleyear <2016), colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
theme(legend.position = "none") +
ggtitle("Infralittoral sand c-squares (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# tidy up
rm(temp)
# make a temporary selection of the test data
temp <- samples_csquares %>%
as.data.frame() %>%
filter(msfd == "Infralittoral mixed sediment", sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id)
# take the bbox limits of the sample data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Infralittoral mixed sediment"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Infralittoral mixed sediment"), fill = "chocolate", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = filter(csquare_grid_test, Id %in% temp$Id), fill = "green", alpha = 0.1) +
geom_sf(data = filter(samples_test, msfd == "Infralittoral mixed sediment", sampleyear <2016), colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
theme(legend.position = "none") +
ggtitle("Infralittoral mixed sediment c-squares (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# tidy up
rm(temp)
# make a temporary selection of the test data
temp <- samples_csquares %>%
as.data.frame() %>%
filter(msfd == "Offshore circalittoral coarse sediment", sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id)
# take the bbox limits of the sample data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Offshore circalittoral coarse sediment"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Offshore circalittoral coarse sediment"), fill = "chocolate", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = filter(csquare_grid_test, Id %in% temp$Id), fill = "green", alpha = 0.1) +
geom_sf(data = filter(samples_test, msfd == "Offshore circalittoral coarse sediment", sampleyear <2016), colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
theme(legend.position = "none") +
ggtitle("Offshore circalittoral coarse sediment (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# tidy up
rm(temp)
# make a temporary selection of the test data
temp <- samples_csquares %>%
as.data.frame() %>%
filter(msfd == "Offshore circalittoral mud", sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id)
# take the bbox limits of the sample data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Offshore circalittoral mud"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Offshore circalittoral mud"), fill = "saddlebrown", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = filter(csquare_grid_test, Id %in% temp$Id), fill = "green", alpha = 0.1) +
geom_sf(data = filter(samples_test, msfd == "Offshore circalittoral mud", sampleyear <2016), colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
theme(legend.position = "none") +
ggtitle("Offshore circalittoral mud c-squares (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# tidy up
rm(temp)
# Count c-squares
samples_csquares %>%
as.data.frame() %>%
filter(grepl("Infralittoral sand|Infralittoral mixed sediment|Offshore circalittoral coarse sediment|Offshore circalittoral mud", msfd),
!grepl("biogenic reef", msfd),
sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id) %>%
group_by(Region, year_cat, msfd) %>%
count() %>%
arrange(desc(msfd), Region) %>%
pivot_wider(
names_from = Region,
values_from = n) %>%
datatable(
caption = "Unique c-squares sampled for each assessment period (test area)",
colnames = c("Broad-scale habitat" = "msfd", "Assessment period" = "year_cat"),
options = list(pageLength = 5),
class = "cell-border",
rownames = FALSE)
Summarise habitat area and total c-squares for each combination of broad-scale habitat, assessment period in the test area
Given the suggestion in the CEMP guidelines (estimating percentage coverage of each habitat) we will try to summarise c-square and total habitat areas as percentage coverage (with some very broad assumptions):
# estimate of c-square area
c_square_area <- 15
# join habitat area and c-squares, calculate as a percentage of habitat area
samples_csquares %>%
as.data.frame() %>%
filter(grepl("Infralittoral sand|Infralittoral mixed sediment|Offshore circalittoral coarse sediment|Offshore circalittoral mud", msfd),
!grepl("biogenic reef", msfd),
sampleyear <2016) %>%
distinct(Region, year_cat, msfd, Id) %>%
group_by(Region, year_cat, msfd) %>%
tally() %>%
left_join(., test_bht_area, by = c("Region" = "region", "msfd" = "msfd")) %>%
mutate(bht_percent = scales::percent(n/(total_km2/c_square_area), accuracy = 0.1)) %>%
select(-c(total_km2, n)) %>%
mutate(msfd = factor(msfd, levels = BHT_order),
Region = factor(Region, levels = region_order)) %>%
arrange(desc(msfd)) %>%
pivot_wider(
names_from = Region,
values_from = bht_percent) %>%
datatable(
caption = "Estimated broad-scale habitat area coverage (test area)",
colnames = c("Broad-scale habitat" = "msfd", "Assessment period" = "year_cat"),
extensions = 'Buttons',
options = list(pageLength = 10,
buttons = c("csv"),
dom = 'Bfrtip',
columnDefs = list(list(className = 'dt-center', targets = 2))),
class = "cell-border",
rownames = FALSE)
rm(c_square_area)
The >100% values in broad-scale habitats highlight some of the limitations when estimating areas (both for habitats and the coverage by unique c-squares sampled). However, the use of unique c-squares sampled at least mitigates some of the spatial aggregations present and helps to give a better representation of spatial coverage than number of samples alone.
Given the broad assumptions when estimating coverage of habitats with c-squares, these estimates should not be considered to fully represent the spatial confidence of the results. Estimates using a spatial buffer around sample points are given below.
The coverage of monitoring data will be estimated here by applying a buffer around sample points, these will be specific to the broad scale habitat and assessment period (2009-2015 and 2016-2020). Estimated coverage will be assessed as a percentage of the total broad scale habitat area (habitat map).
Limitations of any estimation of monitoring coverage still remain with this approach;
Several distances were trialed to try and best estimate coverage of sample points, these buffer estimates used the typical distances between sample points when undertaking systematic grid sampling offshore (1 to 5 km). However, the density of sample points in coastal areas is often much higher, resulting in a over estimation of habitat coverage by sample points when using larger buffer sizes (>3 km).
Buffer sizes around sample points of 1.5 km, 2 km, and 3 km are given as examples below, these were chosen as best representative of typical monitoring strategies (grid arrays).
# buffer distance in meters
buffer_dist_a <- 1500
buffer_dist_b <- 2000
buffer_dist_c <- 3000
create a habitat polygon layer from buffered points
# use infralittoral sand as first example
inf_sand <- samples_test %>%
filter(msfd == "Infralittoral sand",
sampleyear < 2016)
# add first buffer option to points
inf_sand_a <- st_buffer(inf_sand, dist = buffer_dist_a)
# remove transitional waters from habitat area
inf_sand_a <- st_difference(inf_sand_a, trans_waters_test)
# remove any area outside the CP2 region
inf_sand_a <- st_intersection(inf_sand_a, cp2_test)
# dissolve into a single feature
inf_sand_a <- st_union(inf_sand_a)
# ensure layer is a sf object
inf_sand_a <- st_as_sf(inf_sand_a)
# repeat for option b
inf_sand_b <- st_buffer(inf_sand, dist = buffer_dist_b)
inf_sand_b <- st_difference(inf_sand_b, trans_waters_test)
inf_sand_b <- st_intersection(inf_sand_b, cp2_test)
inf_sand_b <- st_union(inf_sand_b)
inf_sand_b <- st_as_sf(inf_sand_b)
# and c
inf_sand_c <- st_buffer(inf_sand, dist = buffer_dist_c)
inf_sand_c <- st_difference(inf_sand_c, trans_waters_test)
inf_sand_c <- st_intersection(inf_sand_c, cp2_test)
inf_sand_c <- st_union(inf_sand_c)
inf_sand_c <- st_as_sf(inf_sand_c)
Plot sampled area over habitat map
# take the bbox limits of the sample data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Infralittoral sand"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Infralittoral sand"), fill = "gold3", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = inf_sand_a, fill = NA, aes(colour = cb_palette[1]), lwd = 0.5) +
geom_sf(data = inf_sand_b, fill = NA, aes(colour = cb_palette[3]), lwd = 0.5) +
geom_sf(data = inf_sand_c, fill = NA, aes(colour = cb_palette[2]), lwd = 0.5) +
geom_sf(data = inf_sand, colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
scale_colour_manual(name = "Distance",
values = cb_palette[1:3], labels = c("1.5 km","2 km", "3 km")) +
ggtitle("Infralittoral sand point buffer (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Add area to buffered sample points
# add area
inf_sand_a$area <- units::set_units(st_area(inf_sand_a), value = km^2)
inf_sand_b$area <- units::set_units(st_area(inf_sand_b), value = km^2)
inf_sand_c$area <- units::set_units(st_area(inf_sand_c), value = km^2)
Calculate the proportional coverage estimate (mapped habitat area and estimated sample coverage)
test_bht_area %>%
ungroup() %>%
filter(msfd == "Infralittoral sand", region == "Irish Sea") %>%
mutate(monitoring_area_a = inf_sand_a$area,
proportion_coverage_a = scales::percent(as.double(inf_sand_a$area)/total_km2, accuracy = 0.1),
monitoring_area_b = inf_sand_b$area,
proportion_coverage_b= scales::percent(as.double(inf_sand_b$area)/total_km2, accuracy = 0.1),
monitoring_area_c = inf_sand_c$area,
proportion_coverage_c = scales::percent(as.double(inf_sand_c$area)/total_km2, accuracy = 0.1)) %>%
select(-c(region))
Estimated sampling for these test data covered 54.0% , 78.3%, or 134.7%
Repeat the above process for infralittoral mixed sediment
create a habitat polygon layer from buffered points
# repeat for example 2 using infralittoral mixed sediment
inf_mixed <- samples_test %>%
filter(msfd == "Infralittoral mixed sediment",
sampleyear < 2016)
# add first buffer to points
inf_mixed_a <- st_buffer(inf_mixed, dist = buffer_dist_a)
# remove transitional waters from habitat area
inf_mixed_a <- st_difference(inf_mixed_a, trans_waters_test)
# remove any area outside the CP2 region
inf_mixed_a <- st_intersection(inf_mixed_a, cp2_test)
# dissolve into a single feature
inf_mixed_a <- st_union(inf_mixed_a)
# ensure layer is a sf object
inf_mixed_a <- st_as_sf(inf_mixed_a)
# repeat for option b
inf_mixed_b <- st_buffer(inf_mixed, dist = buffer_dist_b)
inf_mixed_b <- st_difference(inf_mixed_b, trans_waters_test)
inf_mixed_b <- st_intersection(inf_mixed_b, cp2_test)
inf_mixed_b <- st_union(inf_mixed_b)
inf_mixed_b <- st_as_sf(inf_mixed_b)
# and c
inf_mixed_c <- st_buffer(inf_mixed, dist = buffer_dist_c)
inf_mixed_c <- st_difference(inf_mixed_c, trans_waters_test)
inf_mixed_c <- st_intersection(inf_mixed_c, cp2_test)
inf_mixed_c <- st_union(inf_mixed_c)
inf_mixed_c <- st_as_sf(inf_mixed_c)
Plot sampled area over habitat map
# take the bbox limits of the habitat data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Infralittoral mixed sediment"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Infralittoral mixed sediment"), fill = "chocolate", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = inf_mixed_a, fill = NA, aes(colour = cb_palette[1]), lwd = 0.5) +
geom_sf(data = inf_mixed_b, fill = NA, aes(colour = cb_palette[3]), lwd = 0.5) +
geom_sf(data = inf_mixed_c, fill = NA, aes(colour = cb_palette[2]), lwd = 0.5) +
geom_sf(data = inf_mixed, colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
scale_colour_manual(name = "Distance",
values = cb_palette[1:3], labels = c("1.5 km","2 km", "3 km")) +
ggtitle("Infralittoral mixed sediment point buffer (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Add area to buffered points
# add area
inf_mixed_a$area <- units::set_units(st_area(inf_mixed_a), value = km^2)
inf_mixed_b$area <- units::set_units(st_area(inf_mixed_b), value = km^2)
inf_mixed_c$area <- units::set_units(st_area(inf_mixed_c), value = km^2)
Calculate the proportional coverage estimate
test_bht_area %>%
ungroup() %>%
filter(msfd == "Infralittoral mixed sediment", region == "Irish Sea") %>%
mutate(monitoring_area_a = inf_mixed_a$area,
proportion_coverage_a = scales::percent(as.double(inf_mixed_a$area)/total_km2, accuracy = 0.1),
monitoring_area_b = inf_mixed_b$area,
proportion_coverage_b = scales::percent(as.double(inf_mixed_b$area)/total_km2, accuracy = 0.1),
monitoring_area_c = inf_mixed_c$area,
proportion_coverage_c = scales::percent(as.double(inf_mixed_c$area)/total_km2, accuracy = 0.1)) %>%
select(-c(region))
Estimated sampling for these test data covered 196.9%, 294.4%, or 494.0%
Example using offshore circalittoral coarse sediment
create a habitat polygon layer from buffered points
# repeat again using Offshore circalittoral coarse sediment
off_circ_coarse <- samples_test %>%
filter(msfd == "Offshore circalittoral coarse sediment",
sampleyear < 2016)
# add first buffer to points
off_circ_coarse_a <- st_buffer(off_circ_coarse, dist = buffer_dist_a)
# remove transitional waters from habitat area
off_circ_coarse_a <- st_difference(off_circ_coarse_a, trans_waters_test)
# remove any area outside the CP2 region
off_circ_coarse_a <- st_intersection(off_circ_coarse_a, cp2_test)
# dissolve into a single feature
off_circ_coarse_a <- st_union(off_circ_coarse_a)
# ensure layer is a sf object
off_circ_coarse_a <- st_as_sf(off_circ_coarse_a)
# repeat for option b
off_circ_coarse_b <- st_buffer(off_circ_coarse, dist = buffer_dist_b)
off_circ_coarse_b <- st_difference(off_circ_coarse_b, trans_waters_test)
off_circ_coarse_b <- st_intersection(off_circ_coarse_b, cp2_test)
off_circ_coarse_b <- st_union(off_circ_coarse_b)
off_circ_coarse_b <- st_as_sf(off_circ_coarse_b)
# and c
off_circ_coarse_c <- st_buffer(off_circ_coarse, dist = buffer_dist_c)
off_circ_coarse_c <- st_difference(off_circ_coarse_c, trans_waters_test)
off_circ_coarse_c <- st_intersection(off_circ_coarse_c, cp2_test)
off_circ_coarse_c <- st_union(off_circ_coarse_c)
off_circ_coarse_c <- st_as_sf(off_circ_coarse_c)
Plot sampled area over habitat map
# take the bbox limits of the habitat data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Offshore circalittoral coarse sediment"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Offshore circalittoral coarse sediment"), fill = "chocolate", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = off_circ_coarse_a, fill = NA, aes(colour = cb_palette[5]), lwd = 0.5) +
geom_sf(data = off_circ_coarse_b, fill = NA, aes(colour = cb_palette[3]), lwd = 0.5) +
geom_sf(data = off_circ_coarse_c, fill = NA, aes(colour = cb_palette[4]), lwd = 0.5) +
geom_sf(data = off_circ_coarse, colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
scale_colour_manual(name = "Distance",
values = cb_palette[3:5], labels = c("1.5 km","2 km", "3 km")) +
ggtitle("Offshore circalittoral coarse sediment point buffer (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Add area to buffered points
# add area
off_circ_coarse_a$area <- units::set_units(st_area(off_circ_coarse_a), value = km^2)
off_circ_coarse_b$area <- units::set_units(st_area(off_circ_coarse_b), value = km^2)
off_circ_coarse_c$area <- units::set_units(st_area(off_circ_coarse_c), value = km^2)
Calculate proportional coverage estimate
test_bht_area %>%
ungroup() %>%
filter(msfd == "Offshore circalittoral coarse sediment", region == "Irish Sea") %>%
mutate(monitoring_area_a = off_circ_coarse_a$area,
proportion_coverage_a = scales::percent(as.double(off_circ_coarse_a$area)/total_km2, accuracy = 0.1),
monitoring_area_b = off_circ_coarse_b$area,
proportion_coverage_b = scales::percent(as.double(off_circ_coarse_b$area)/total_km2, accuracy = 0.1),
monitoring_area_c = off_circ_coarse_c$area,
proportion_coverage_c = scales::percent(as.double(off_circ_coarse_c$area)/total_km2, accuracy = 0.1)) %>%
select(-c(region))
Estimated sampling for these test data covered 13.9%, 21.5%, or 36.2%
Example using offshore circalittoral mud
create a habitat polygon layer from buffered points
# repeat again using Offshore circalittoral mud
off_circ_mud <- samples_test %>%
filter(msfd == "Offshore circalittoral mud",
sampleyear < 2016)
# add first buffer to points
off_circ_mud_a <- st_buffer(off_circ_mud, dist = buffer_dist_a)
# remove transitional waters from habitat area
off_circ_mud_a <- st_difference(off_circ_mud_a, trans_waters_test)
# remove any area outside the CP2 region
off_circ_mud_a <- st_intersection(off_circ_mud_a, cp2_test)
# dissolve into a single feature
off_circ_mud_a <- st_union(off_circ_mud_a)
# ensure layer is a sf object
off_circ_mud_a <- st_as_sf(off_circ_mud_a)
# repeat for option b
off_circ_mud_b <- st_buffer(off_circ_mud, dist = buffer_dist_b)
off_circ_mud_b <- st_difference(off_circ_mud_b, trans_waters_test)
off_circ_mud_b <- st_intersection(off_circ_mud_b, cp2_test)
off_circ_mud_b <- st_union(off_circ_mud_b)
off_circ_mud_b <- st_as_sf(off_circ_mud_b)
# and c
off_circ_mud_c <- st_buffer(off_circ_mud, dist = buffer_dist_c)
off_circ_mud_c <- st_difference(off_circ_mud_c, trans_waters_test)
off_circ_mud_c <- st_intersection(off_circ_mud_c, cp2_test)
off_circ_mud_c <- st_union(off_circ_mud_c)
off_circ_mud_c <- st_as_sf(off_circ_mud_c)
Plot sampled area over habitat map
# take the bbox limits of the habitat data (to focus plot)
bbox_lim <- st_bbox(filter(habitat_test, msfd == "Offshore circalittoral mud"))
# plot
ggplot() +
geom_sf(data = land_test, fill = "grey", colour = NA) +
geom_sf(data = trans_waters_test, fill = "grey30", colour = NA) +
geom_sf(data = filter(habitat_test, msfd == "Offshore circalittoral mud"), fill = "saddlebrown", colour = NA) +
geom_sf(data = cp2_test, colour = "navy", fill = NA, alpha = 0.6, lwd = 0.5) +
geom_sf(data = off_circ_mud_a, fill = NA, aes(colour = cb_palette[1]), lwd = 0.5) +
geom_sf(data = off_circ_mud_b, fill = NA, aes(colour = cb_palette[3]), lwd = 0.5) +
geom_sf(data = off_circ_mud_c, fill = NA, aes(colour = cb_palette[2]), lwd = 0.5) +
geom_sf(data = off_circ_mud, colour = "black", size = 0.3) +
geom_sf(data = test_area, fill = "transparent", color = "grey50") +
theme_bw() +
scale_colour_manual(name = "Distance",
values = cb_palette[1:3], labels = c("1.5 km","2 km", "3 km")) +
ggtitle("Offshore circalittoral mud point buffer (2009-2015)") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Add area to buffered points
# add area
off_circ_mud_a$area <- units::set_units(st_area(off_circ_mud_a), value = km^2)
off_circ_mud_b$area <- units::set_units(st_area(off_circ_mud_b), value = km^2)
off_circ_mud_c$area <- units::set_units(st_area(off_circ_mud_c), value = km^2)
Calculate proportional coverage estimate
test_bht_area %>%
ungroup() %>%
filter(msfd == "Offshore circalittoral mud", region == "Irish Sea") %>%
mutate(monitoring_area_a = off_circ_mud_a$area,
proportion_coverage_a = scales::percent(as.double(off_circ_mud_a$area)/total_km2, accuracy = 0.1),
monitoring_area_b = off_circ_mud_b$area,
proportion_coverage_b = scales::percent(as.double(off_circ_mud_b$area)/total_km2, accuracy = 0.1),
monitoring_area_c = off_circ_mud_c$area,
proportion_coverage_c = scales::percent(as.double(off_circ_mud_c$area)/total_km2, accuracy = 0.1)) %>%
select(-c(region))
Estimated sampling for these test data covered 17.7%, 27.4%, or 49.5%
Summary of the proportion of sample coverage estimates using the three different buffer options in the test area.
# create a summary table of the buffer size options
test_bht_area %>%
ungroup() %>%
filter(grepl("Infralittoral sand|Infralittoral mixed sediment|Offshore circalittoral coarse sediment|Offshore circalittoral mud", msfd),
region == "Irish Sea", !grepl("biogenic reef", msfd)) %>%
select(-c(region)) %>%
mutate(proportion_a = case_when(grepl("Infralittoral sand", msfd) ~ scales::percent(as.double(inf_sand_a$area)/total_km2, accuracy = 0.1),
grepl("Infralittoral mixed sediment", msfd) ~ scales::percent(as.double(inf_mixed_a$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral coarse sediment", msfd) ~ scales::percent(as.double(off_circ_coarse_a$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral mud", msfd) ~ scales::percent(as.double(off_circ_mud_a$area)/total_km2, accuracy = 0.1)),
proportion_b = case_when(grepl("Infralittoral sand", msfd) ~ scales::percent(as.double(inf_sand_b$area)/total_km2, accuracy = 0.1),
grepl("Infralittoral mixed sediment", msfd) ~ scales::percent(as.double(inf_mixed_b$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral coarse sediment", msfd) ~ scales::percent(as.double(off_circ_coarse_b$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral mud", msfd) ~ scales::percent(as.double(off_circ_mud_b$area)/total_km2, accuracy = 0.1)),
proportion_c = case_when(grepl("Infralittoral sand", msfd) ~ scales::percent(as.double(inf_sand_c$area)/total_km2, accuracy = 0.1),
grepl("Infralittoral mixed sediment", msfd) ~ scales::percent(as.double(inf_mixed_c$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral coarse sediment", msfd) ~ scales::percent(as.double(off_circ_coarse_c$area)/total_km2, accuracy = 0.1),
grepl("Offshore circalittoral mud", msfd) ~ scales::percent(as.double(off_circ_mud_c$area)/total_km2, accuracy = 0.1)),
total_km2 = round(total_km2, 1)) %>%
datatable(
caption = "Estimated broad-scale habitat area coverage in example area",
colnames = c("Broad-scale habitat" = "msfd",
"1.5 km buffer" = "proportion_a",
"2 km buffer" = "proportion_b",
"3 km buffer" = "proportion_c"),
extensions = 'Buttons',
options = list(pageLength = 25,
buttons = c("csv"),
dom = 'Brtip',
columnDefs = list(list(className = 'dt-center', targets = 1:4))),
class = "cell-border",
rownames = FALSE)
The area “monitored” by the sample data was considered to be most accurately represented by the bufferd points method using a distance of 2 km around sample locations. However, this method is still likely to overestimate representative area for some habitat (e.g., infralittoral mixed sediment).
Estimates of spatial representation are here summarised for all broad scale habitats, specific to the assessment periods and assessment areas (CP2 Regions)
# set buffer distance in meters
buffer_dist <- 2000
Create a selection of the area of interest
# define CP2 Region for selection
selected_region <- "Scottish Continental Shelf"
# select only one CP2 region
cp2_scottish_con_shelf <- cp2 %>%
filter(Region == "Scottish Continental Shelf")
# select samples in the region, take only the necessary fields
samples_scottish_con_shelf <- samples_SAR_rel_LAEA %>%
select(sampleref:sampleyear, hab_type, msfd, D_rel, Region, RegionID) %>%
mutate(year_cat = if_else(sampleyear <2016, "2009-2015", "2016-2021")) %>%
filter(Region == "Scottish Continental Shelf")
# take the spatial limits of the region
bbox_text <- bbox_to_text_LAEA(cp2_scottish_con_shelf)
# load in the habitat map in the selection area
habitat_selection <- st_read("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg", layer = "C20230725_CS_cp2_bht_LAEA_GF", wkt_filter = bbox_text)
# select the cp2 region
habitat_cp2_scottish_con_shelf <- habitat_selection %>%
filter(region == "Scottish Continental Shelf")
# remove areas with missing habitat information
habitat_cp2_scottish_con_shelf <- habitat_cp2_scottish_con_shelf %>%
filter(!grepl("No EUNIS| rock", msfd))
# remove any habitat area in transitional waters (not assessed with BH2b)
habitat_cp2_scottish_con_shelf <- st_difference(habitat_cp2_scottish_con_shelf, trans_waters_LAEA)
Plot the habitat map and sample points
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_scottish_con_shelf)
# plot habitat map and samples
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = habitat_cp2_scottish_con_shelf, aes(fill = msfd), colour = NA) +
geom_sf(data = cp2_scottish_con_shelf, colour = "navy", fill = NA, lwd = 0.5) +
geom_sf(data = samples_scottish_con_shelf, colour = "red", size = 0.2) +
scale_fill_viridis_d(direction = -1) +
theme(legend.position = "none") +
ggtitle("Scottish Continental Shelf habitat area") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Calculate habitat area in the assessment region
# recalculate feature areas following processing
habitat_cp2_scottish_con_shelf_area <- habitat_cp2_scottish_con_shelf %>%
mutate(area_km2 = as.double(area_sf/1000000)) %>%
as.data.frame() %>%
group_by(region, msfd) %>%
summarise(total_km2 = sum(area_km2))
# show total area in a table
habitat_cp2_scottish_con_shelf_area %>%
ungroup() %>%
mutate(msfd = factor(msfd, levels = BHT_order)) %>%
select(msfd, total_km2) %>%
arrange(desc(msfd)) %>%
mutate(total_km2 = round(total_km2, 1)) %>%
datatable(
caption = "Broad scale abitat area in the Scottish Continental Shelf CP2 Region",
colnames = c("Broad scale habitat" = "msfd", "Total km2" = "total_km2"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1))),
class = "cell-border",
rownames = FALSE)
Create buffered polygon layer from sample points for each broad scale habitat
Note the Scottish Continental Shelf CP2 Region does not need to be split by assessment period (2009-2015 and 2016-2021), all sample data is pre 2016.
# add buffer to points
samples_scottish_con_shelf_area <- st_buffer(samples_scottish_con_shelf, dist = buffer_dist)
# remove anything outside the assessment area
samples_scottish_con_shelf_area <- st_intersection(samples_scottish_con_shelf_area, cp2_scottish_con_shelf)
# union broad scale habitats and add median Dm
samples_scottish_con_shelf_area <- samples_scottish_con_shelf_area %>%
group_by(msfd, year_cat) %>%
summarise(geometry = st_union(geometry),
n = n(),
D_agg = median(D_rel)) %>%
st_as_sf()
# calculate area for each sampled habitat
samples_scottish_con_shelf_area$area <- units::set_units(st_area(samples_scottish_con_shelf_area), value = km^2)
Plot sample coverage in the Scottish Continental Shelf
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_scottish_con_shelf)
# plot sampled habitat buffers (2009-2015)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_scottish_con_shelf, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = samples_scottish_con_shelf_area, aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 40)) +
theme(legend.position = "bottom") +
ggtitle("Scottish Continental Shelf 2009-2015") +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Summarise the representation of area sampled for each broad scale habitat
# joint point buffer layer to habitat totals
scottish_con_shelf_summary <- habitat_cp2_scottish_con_shelf_area %>%
left_join(as.data.frame(samples_scottish_con_shelf_area), by = c("msfd" = "msfd")) %>%
select(-c(geometry)) %>%
mutate(prop = (as.double(area)/total_km2),
prop_rep = case_when(prop >1 ~ ">100%",
TRUE ~ scales::percent(prop, accuracy = 0.1)))
# give a summary table
scottish_con_shelf_summary %>%
ungroup() %>%
select(msfd, year_cat, total_km2, n, area, prop_rep) %>%
mutate(total_km2 = round(total_km2, 1),
area = round(area, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " proportional representation"),
colnames = c("Broad scale habitat" = "msfd",
"Period" = "year_cat",
"Total km2" = "total_km2",
"Samples(n)" = "n",
"Representation" = "prop_rep"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1:4))),
class = "cell-border",
rownames = FALSE)
# tidy up
rm(selected_region, cp2_scottish_con_shelf, habitat_cp2_scottish_con_shelf, habitat_cp2_scottish_con_shelf_area, bbox_text, habitat_selection, bbox_lim)
Create a selection of the area of interest
# define CP2 Region for selection
selected_region <- "Minches & Western Scotland"
# select only one CP2 region
cp2_selected <- cp2 %>%
filter(Region == selected_region)
# select samples in the region, take only the necessary fields
samples_selected <- samples_SAR_rel_LAEA %>%
select(sampleref:sampleyear, hab_type, msfd, D_rel, Region, RegionID) %>%
mutate(year_cat = if_else(sampleyear <2016, "2009-2015", "2016-2021")) %>%
filter(Region == selected_region)
# load in the habitat map in the region needed
first_layer <- st_layers("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg")$name[1]
habitat_selection = st_read("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg",
query = sprintf("SELECT * FROM \"%s\" WHERE region = \"Minches & Western Scotland\"", first_layer))
# fix geometry
habitat_selection <- st_make_valid(habitat_selection)
# remove areas with missing habitat information
habitat_selection <- habitat_selection %>%
filter(!grepl("No EUNIS| rock", msfd))
# remove any habitat area in transitional waters (not assessed with BH2b)
habitat_selection <- st_difference(habitat_selection, trans_waters_LAEA)
# tidy up
rm(first_layer)
Plot the habitat map and sample points
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot habitat map and samples
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = habitat_selection, aes(fill = msfd), colour = NA) +
geom_sf(data = cp2_selected, colour = "navy", fill = NA, lwd = 0.5) +
geom_sf(data = samples_selected, colour = "red", size = 0.2) +
scale_fill_viridis_d(direction = -1) +
theme(legend.position = "none") +
ggtitle(paste0(selected_region, " habitat area")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Calculate habitat area in the assessment region
# recalculate feature areas following processing
habitat_cp2_minches_western_scotland_area <- habitat_selection %>%
mutate(area_km2 = as.double(area_sf/1000000)) %>%
as.data.frame() %>%
group_by(region, msfd) %>%
summarise(total_km2 = sum(area_km2))
# show total area in a table
habitat_cp2_minches_western_scotland_area %>%
ungroup() %>%
mutate(msfd = factor(msfd, levels = BHT_order)) %>%
select(msfd, total_km2) %>%
arrange(desc(msfd)) %>%
mutate(total_km2 = round(total_km2, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " CP2 Region"),
colnames = c("Broad scale habitat" = "msfd", "Total km2" = "total_km2"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1))),
class = "cell-border",
rownames = FALSE)
Create buffered polygon layer from sample points for each broad scale habitat
# add buffer to points
samples_selected_area <- st_buffer(samples_selected, dist = buffer_dist)
# remove anything outside the assessment area
samples_selected_area <- st_intersection(samples_selected_area, cp2_selected)
# union broad scale habitats and add median Dm
samples_selected_area <- samples_selected_area %>%
group_by(msfd, year_cat) %>%
summarise(geometry = st_union(geometry),
n = n(),
D_agg = median(D_rel)) %>%
st_as_sf()
# calculate area for each sampled habitat
samples_selected_area$area <- units::set_units(st_area(samples_selected_area), value = km^2)
Plot sample coverage in the Scottish Continental Shelf
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot sampled habitat buffers (2009-2015)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2009-2015"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2009-2015")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# plot sampled habitat buffers (2016-2021)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2016-2021"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2016-2021")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Summarise the representation of area sampled for each broad scale habitat
# joint point buffer layer to habitat totals
minches_western_scotland_summary <- habitat_cp2_minches_western_scotland_area %>%
left_join(as.data.frame(samples_selected_area), by = c("msfd" = "msfd")) %>%
select(-c(geometry)) %>%
mutate(prop = (as.double(area)/total_km2),
prop_rep = case_when(prop >1 ~ ">100%",
TRUE ~ scales::percent(prop, accuracy = 0.1)))
# give a summary table
minches_western_scotland_summary %>%
ungroup() %>%
select(msfd, year_cat, total_km2, n, area, prop_rep) %>%
mutate(total_km2 = round(total_km2, 1),
area = round(area, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " proportional representation"),
colnames = c("Broad scale habitat" = "msfd",
"Period" = "year_cat",
"Total km2" = "total_km2",
"Samples(n)" = "n",
"Representation" = "prop_rep"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1:5))),
class = "cell-border",
rownames = FALSE)
# tidy up
rm(selected_region, cp2_selected, habitat_selection, bbox_lim)
Create a selection of the area of interest
# define CP2 Region for selection
selected_region <- "Irish Sea"
# select only one CP2 region
cp2_selected <- cp2 %>%
filter(Region == selected_region)
# select samples in the region, take only the necessary fields
samples_selected <- samples_SAR_rel_LAEA %>%
select(sampleref:sampleyear, hab_type, msfd, D_rel, Region, RegionID) %>%
mutate(year_cat = if_else(sampleyear <2016, "2009-2015", "2016-2021")) %>%
filter(Region == selected_region)
# load in the habitat map in the region needed
first_layer <- st_layers("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg")$name[1]
habitat_selection = st_read("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg",
query = sprintf("SELECT * FROM \"%s\" WHERE region = \"Irish Sea\"", first_layer))
# fix geometry
habitat_selection <- st_make_valid(habitat_selection)
# remove areas with missing habitat information
habitat_selection <- habitat_selection %>%
filter(!grepl("No EUNIS| rock", msfd))
# remove any habitat area in transitional waters (not assessed with BH2b)
habitat_selection <- st_difference(habitat_selection, trans_waters_LAEA)
# tidy up
rm(first_layer)
Plot the habitat map and sample points
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot habitat map and samples
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = habitat_selection, aes(fill = msfd), colour = NA) +
geom_sf(data = cp2_selected, colour = "navy", fill = NA, lwd = 0.5) +
geom_sf(data = samples_selected, colour = "red", size = 0.2) +
scale_fill_viridis_d(direction = -1) +
theme(legend.position = "none") +
ggtitle(paste0(selected_region, " habitat area")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Calculate habitat area in the assessment region
# recalculate feature areas following processing
habitat_cp2_irish_sea_area <- habitat_selection %>%
mutate(area_km2 = as.double(area_sf/1000000)) %>%
as.data.frame() %>%
group_by(region, msfd) %>%
summarise(total_km2 = sum(area_km2))
# show total area in a table
habitat_cp2_irish_sea_area %>%
ungroup() %>%
mutate(msfd = factor(msfd, levels = BHT_order)) %>%
select(msfd, total_km2) %>%
arrange(desc(msfd)) %>%
mutate(total_km2 = round(total_km2, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " CP2 Region"),
colnames = c("Broad scale habitat" = "msfd", "Total km2" = "total_km2"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1))),
class = "cell-border",
rownames = FALSE)
Create buffered polygon layer from sample points for each broad scale habitat
# add buffer to points
samples_selected_area <- st_buffer(samples_selected, dist = buffer_dist)
# remove anything outside the assessment area
samples_selected_area <- st_intersection(samples_selected_area, cp2_selected)
# union broad scale habitats and add median Dm
samples_selected_area <- samples_selected_area %>%
group_by(msfd, year_cat) %>%
summarise(geometry = st_union(geometry),
n = n(),
D_agg = median(D_rel)) %>%
st_as_sf()
# calculate area for each sampled habitat
samples_selected_area$area <- units::set_units(st_area(samples_selected_area), value = km^2)
Plot sample coverage in the Scottish Continental Shelf
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot sampled habitat buffers (2009-2015)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2009-2015"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2009-2015")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# plot sampled habitat buffers (2016-2021)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2016-2021"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2016-2021")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Summarise the representation of area sampled for each broad scale habitat
# joint point buffer layer to habitat totals
irish_sea_summary <- habitat_cp2_irish_sea_area %>%
left_join(as.data.frame(samples_selected_area), by = c("msfd" = "msfd")) %>%
select(-c(geometry)) %>%
mutate(prop = (as.double(area)/total_km2),
prop_rep = case_when(prop >1 ~ ">100%",
TRUE ~ scales::percent(prop, accuracy = 0.1)))
# give a summary table
irish_sea_summary %>%
ungroup() %>%
select(msfd, year_cat, total_km2, n, area, prop_rep) %>%
mutate(total_km2 = round(total_km2, 1),
area = round(area, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " proportional representation"),
colnames = c("Broad scale habitat" = "msfd",
"Period" = "year_cat",
"Total km2" = "total_km2",
"Samples(n)" = "n",
"Representation" = "prop_rep"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1:4))),
class = "cell-border",
rownames = FALSE)
# tidy up
rm(selected_region, cp2_selected, habitat_selection, bbox_lim)
Create a selection of the area of interest
# define CP2 Region for selection
selected_region <- "Western Channel & Celtic Sea"
# select only one CP2 region
cp2_selected <- cp2 %>%
filter(Region == selected_region)
# select samples in the region, take only the necessary fields
samples_selected <- samples_SAR_rel_LAEA %>%
select(sampleref:sampleyear, hab_type, msfd, D_rel, Region, RegionID) %>%
mutate(year_cat = if_else(sampleyear <2016, "2009-2015", "2016-2021")) %>%
filter(Region == selected_region)
# load in the habitat map in the region needed
first_layer <- st_layers("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg")$name[1]
habitat_selection = st_read("Data/Processed/Spatial/CS_cp2_bht_LAEA.gpkg",
query = sprintf("SELECT * FROM \"%s\" WHERE region = \"Western Channel & Celtic Sea\"", first_layer))
# fix geometry
habitat_selection <- st_make_valid(habitat_selection)
# remove areas with missing habitat information
habitat_selection <- habitat_selection %>%
filter(!grepl("No EUNIS| rock", msfd))
# remove any habitat area in transitional waters (not assessed with BH2b)
habitat_selection <- st_difference(habitat_selection, trans_waters_LAEA)
# tidy up
rm(first_layer)
Plot the habitat map and sample points
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot habitat map and samples
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = habitat_selection, aes(fill = msfd), colour = NA) +
geom_sf(data = cp2_selected, colour = "navy", fill = NA, lwd = 0.5) +
geom_sf(data = samples_selected, colour = "red", size = 0.2) +
scale_fill_viridis_d(direction = -1) +
theme(legend.position = "none") +
ggtitle(paste0(selected_region, " habitat area")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Calculate habitat area in the assessment region
# recalculate feature areas following processing
habitat_cp2_western_channel_area <- habitat_selection %>%
mutate(area_km2 = as.double(area_sf/1000000)) %>%
as.data.frame() %>%
group_by(region, msfd) %>%
summarise(total_km2 = sum(area_km2))
# show total area in a table
habitat_cp2_western_channel_area %>%
ungroup() %>%
mutate(msfd = factor(msfd, levels = BHT_order)) %>%
select(msfd, total_km2) %>%
arrange(desc(msfd)) %>%
mutate(total_km2 = round(total_km2, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " CP2 Region"),
colnames = c("Broad scale habitat" = "msfd", "Total km2" = "total_km2"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1))),
class = "cell-border",
rownames = FALSE)
Create buffered polygon layer from sample points for each broad scale habitat
# add buffer to points
samples_selected_area <- st_buffer(samples_selected, dist = buffer_dist)
# remove anything outside the assessment area
samples_selected_area <- st_intersection(samples_selected_area, cp2_selected)
# union broad scale habitats and add median Dm
samples_selected_area <- samples_selected_area %>%
group_by(msfd, year_cat) %>%
summarise(geometry = st_union(geometry),
n = n(),
D_agg = median(D_rel)) %>%
st_as_sf()
# calculate area for each sampled habitat
samples_selected_area$area <- units::set_units(st_area(samples_selected_area), value = km^2)
Plot sample coverage in the Scottish Continental Shelf
# take the bbox limits to focus plot
bbox_lim <- st_bbox(cp2_selected)
# plot sampled habitat buffers (2009-2015)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2009-2015"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2009-2015")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
# plot sampled habitat buffers (2016-2021)
ggplot() +
geom_sf(data = land_cs_LAEA, fill = "grey", colour = NA) +
geom_sf(data = cp2_selected, colour = "grey20", fill = NA, lwd = 0.3) +
geom_sf(data = filter(samples_selected_area, year_cat == "2016-2021"), aes(fill = msfd), colour = NA, alpha = 0.8) +
scale_fill_viridis_d(direction = 1,
name = "Broad-scale habitat",
labels = ~ stringr::str_wrap(.x, width = 30)) +
theme(legend.position = "right") +
ggtitle(paste0(selected_region, " 2016-2021")) +
ylim(bbox_lim[2], bbox_lim[4]) +
xlim(bbox_lim[1], bbox_lim[3])
Summarise the representation of area sampled for each broad scale habitat
# joint point buffer layer to habitat totals
western_channel_summary <- habitat_cp2_western_channel_area %>%
left_join(as.data.frame(samples_selected_area), by = c("msfd" = "msfd")) %>%
select(-c(geometry)) %>%
mutate(prop = (as.double(area)/total_km2),
prop_rep = case_when(prop >1 ~ ">100%",
TRUE ~ scales::percent(prop, accuracy = 0.1)))
# give a summary table
western_channel_summary %>%
ungroup() %>%
select(msfd, year_cat, total_km2, n, area, prop_rep) %>%
mutate(total_km2 = round(total_km2, 1),
area = round(area, 1)) %>%
datatable(
caption = paste0("Broad scale abitat area in the ", selected_region, " proportional representation"),
colnames = c("Broad scale habitat" = "msfd",
"Period" = "year_cat",
"Total km2" = "total_km2",
"Samples(n)" = "n",
"Representation" = "prop_rep"),
extensions = 'Buttons',
options = list(pageLength = 10,
dom = 'Bfrtip',
buttons = c('copy', 'csv'),
columnDefs = list(list(className = 'dt-center', targets = 1:4))),
class = "cell-border",
rownames = FALSE)
# tidy up
rm(selected_region, cp2_selected, habitat_selection, bbox_lim)
Join results from all CP2 Regions into a single table
# join cp2 regions
spatial_summary <- rbind(scottish_con_shelf_summary, minches_western_scotland_summary, irish_sea_summary, western_channel_summary)
# summarise
spatial_summary %>%
select(region, msfd, year_cat, prop_rep) %>%
filter(!is.na(year_cat)) %>%
mutate(msfd = factor(msfd, levels = BHT_order),
region = factor(region, levels = region_order)) %>%
arrange(region) %>%
pivot_wider(
names_from = region,
values_from = prop_rep) %>%
arrange(desc(msfd), year_cat) %>%
datatable(
caption = "Estimated broad-scale habitat area coverage",
colnames = c("Broad-scale habitat" = "msfd"),
extensions = 'Buttons',
options = list(pageLength = 10,
buttons = c("csv"),
dom = 'Brtip',
columnDefs = list(list(className = 'dt-center', targets = 2:5))),
class = "cell-border",
rownames = FALSE)
Save processed data
## Save summary
saveRDS(spatial_summary, paste0("Data/Processed/R_data/", creation_date(),"_spatial_summary"))
The analysis above should only be used as an additional resource when considering confidence in the results, it does not make any recommendation of the sampling effort required to make regional assessment of habitat condition.
details::details(sessionInfo(), summary = 'sessionInfo')
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] viridis_0.6.2 viridisLite_0.4.0 RColorBrewer_1.1-2 details_0.3.0
[5] DT_0.26 ggnewscale_0.4.8 sf_0.9-8 forcats_0.5.1
[9] stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4 readr_2.1.0
[13] tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
[17] rprojroot_2.0.3
loaded via a namespace (and not attached):
[1] httr_1.4.2 sass_0.4.4 jsonlite_1.7.2 modelr_0.1.8
[5] bslib_0.4.1 assertthat_0.2.1 highr_0.9 cellranger_1.1.0
[9] yaml_2.2.1 pillar_1.6.4 backports_1.3.0 glue_1.5.0
[13] digest_0.6.28 rvest_1.0.2 colorspace_2.0-2 htmltools_0.5.2
[17] clipr_0.7.1 pkgconfig_2.0.3 broom_0.7.10 haven_2.4.3
[21] scales_1.1.1 tzdb_0.2.0 proxy_0.4-27 farver_2.1.0
[25] generics_0.1.1 ellipsis_0.3.2 cachem_1.0.6 withr_2.5.0
[29] cli_3.1.0 magrittr_2.0.1 crayon_1.4.2 readxl_1.3.1
[33] evaluate_0.18 fs_1.5.0 fansi_0.5.0 xml2_1.3.2
[37] class_7.3-15 tools_3.6.1 hms_1.1.1 lifecycle_1.0.1
[41] munsell_0.5.0 reprex_2.0.1 compiler_3.6.1 jquerylib_0.1.4
[45] e1071_1.7-11 rlang_0.4.12 classInt_0.4-3 units_0.8-0
[49] grid_3.6.1 rstudioapi_0.13 htmlwidgets_1.5.4 crosstalk_1.2.0
[53] rmarkdown_2.18 gtable_0.3.0 DBI_1.1.3 R6_2.5.1
[57] gridExtra_2.3 lubridate_1.8.0 knitr_1.41 fastmap_1.1.0
[61] utf8_1.2.2 KernSmooth_2.23-15 desc_1.4.2 stringi_1.7.5
[65] Rcpp_1.0.10 vctrs_0.3.8 png_0.1-7 dbplyr_2.1.1
[69] tidyselect_1.1.1 xfun_0.35