Section 8 Field Site Properties
For various use-cases across the modelling project, we will require certain information about the locations of the field sites. This section gathers that information and makes it available to other sections.
8.1 Determining the HSG group of the logger sites
require(sf)
require(readr)
require(DT)
require(dplyr)
require(mapview)
require(ggplot2)
sf_theme <- theme(axis.text.x=element_blank(), #remove x axis labels
axis.ticks.x=element_blank(), #remove x axis ticks
axis.text.y=element_blank(), #remove y axis labels
axis.ticks.y=element_blank() #remove y axis ticks
)
We load the soil map of the agricultural area.
We will crop it by the watershed. Therefore we load the watershed
cs10_basin_path <- "model_data/input/shape/cs10_basin_1m.shp"
cs10_basin <- read_sf(cs10_basin_path)
# reproject
cs10_basin <- st_transform(cs10_basin, st_crs(soil_map_shp))
And crop by by basin. (current not sure of the effect of constant geometry)
st_agr(soil_map_shp) = "constant"
st_agr(cs10_basin) = "constant"
soil_map_shp <- st_intersection(soil_map_shp, cs10_basin)
We need information on the soil itself. This is found in our user table. We only
need the hydrologic soil group (HSG) HYDGRP
, but we will keep the soil depth
SOL_ZMX
and soil texture TEXTURE
just in case
# TODO update this path
usersoil_path <- "model_data/input/soil/usersoil_80.csv"
usersoil <- read_csv(usersoil_path, show_col_types = F)
usersoil <- usersoil %>% dplyr::select(OBJECTID, SNAM, SOL_ZMX, HYDGRP, TEXTURE)
We can combine the two data sets with a left join by soil name
usersoil$name <- usersoil$SNAM
soil_propery_map <- dplyr::left_join(soil_map_shp, usersoil, by = "name")
Now we need the locations of the field sites. These are stored as points in the following file:
cs10_field_sites_path <- "model_data/field_sites/geospatial/cs10_field_sites.shp"
cs10_field_sites <- read_sf(cs10_field_sites_path)
We are going to join the attributes using a spatial join
cs10_field_sites <- st_transform(cs10_field_sites, crs = st_crs(soil_propery_map))
field_sites_attr <- st_join(cs10_field_sites, soil_propery_map)
Here is the result:
We have two sites covering C and D, and one site covering B. This covers all existing HSGs in the catchment, which is good. We can save this information in a dataframe.
(UPDATE: with new soil data this is no longer the case)
We will write this into our output folder
And save our soil property map, and field site points (with attributes)