Title: | BC Aquifer data tools |
---|---|
Description: | Set of tools for processing BC Aquifer lithology and yield data. |
Authors: | Steffi LaZerte [aut, cre] , Christine Bieber [aut], Province of British Columbia [cph] |
Maintainer: | Steffi LaZerte <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.0.3 |
Built: | 2024-11-16 03:36:07 UTC |
Source: | https://github.com/bcgov/bcaquiferdata |
This app allows you to load a shapefile and filter aquifer/well data according to region, explore data, and export cleaned files.
aq_app()
aq_app()
aq_app()
aq_app()
Removes data cache
cache_clean(bcmaps_cded = FALSE)
cache_clean(bcmaps_cded = FALSE)
bcmaps_cded |
Logical. Whether or not to also remove CDED files cached with the bcmaps package. These are used by bcaquifertools for acquiring TRIM data, but may also be cached for use by other workflows. |
# cache_clean() # cache_clean(bcmaps_cded = TRUE)
# cache_clean() # cache_clean(bcmaps_cded = TRUE)
This function downloads, updates or loads locally stored data. Currently this
function returns wells
, wells_sf
, or lithology
data. Note that these
data are originally from GWELLS, but are cleaned and summarized for use in
the bcaquiferdata package. For example wells_sf
is a spatial version of the
data, and lithology
is a cleaned and standardized version of lithology.
wells
also contains the new standardized lithology
data, along with the
original lithology observations and intermediate classification steps to
simplify error tracing.
data_read(type, update = FALSE, permission = FALSE)
data_read(type, update = FALSE, permission = FALSE)
type |
Character. Type of data to return, one of |
update |
Logical. Force update of the data? |
permission |
Logical. Permission to create the cache folder. If |
Under normal circumstances, users will not need to use this function as it is used internally by the main workflow functions. However, users may wish to overview entire datasets.
Bear in mind that the lithology cleaning and standardizing, while better than the original data, will almost certainly still have errors!
Data frame or spatial features object of the requested data.
wells <- data_read("wells")
wells <- data_read("wells")
Update the GWELLs data stored locally.
data_update(type = "all", download = TRUE, permission = FALSE)
data_update(type = "all", download = TRUE, permission = FALSE)
type |
Character. Type of data to update. One of "all", "wells", "lithology" |
download |
Logical. Whether to re-download and process the data
( |
permission |
Logical. Permission to create the cache folder. If |
data_update(type = "lithology")
data_update(type = "lithology")
This function takes a shape file of a region and creates a DEM of the region.
Lidar data is stored locally as tiles. Tiles are only downloaded if they
don't already exist unless only_new = FALSE
. TRIM data is obtained via the
bcmaps
package and stored locally as tiles. Note: TRIM elevation is
coarser than Lidar Use Lidar unless it is missing for your region of
interest.
dem_region( region, type = "lidar", buffer = 1, lidar_dir = NULL, only_new = TRUE, progress = httr::progress() )
dem_region( region, type = "lidar", buffer = 1, lidar_dir = NULL, only_new = TRUE, progress = httr::progress() )
region |
sf simple features object. Shape file of the region of interest. |
type |
Character. Type of DEM to download, either "lidar" or "trim". Use Lidar unless unavailable. |
buffer |
Numeric. Percent buffer to apply to the |
lidar_dir |
Character. File path of where Lidar tiles should be stored.
Defaults to the cache directory. Only applies when |
only_new |
Logical. Whether to download all Lidar tiles, or only new
tiles that don't exist locally. Defaults to TRUE. Only apples when |
progress |
Function. Progress bar to use. Generally leave as is. |
Lidar tiles are the newest tile available. If you have reason to need a historical file, contact the team to discuss your use case.
stars spatiotemporal array object
Lidar data is obtained from the LidarBC portal. The tiles
data frame
contains is an internally created data frame listing tiles and their
respective download locations. Tiles to download are selected based on
overlap between map tiles and the provided shapefile (region
). These Lidar
tiles can be browsed and downloaded manually via the
LidarBC Open LiDAR Data Portal
The grid of map tiles is obtained from the BC Data Catalogue, BCGS 1:20,000 Grid
TRIM data is obtained via the bcmaps
package from the BC government
Data Catalogue
based on overlap between map tiles and the provided shapefile (region
).
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Fetch Lidar DEM creek_lidar <- dem_region(creek_sf) plot(creek_lidar) # Fetch TRIM DEM creek_trim <- dem_region(creek_sf, type = "trim") plot(creek_trim)
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Fetch Lidar DEM creek_lidar <- dem_region(creek_sf) plot(creek_lidar) # Fetch TRIM DEM creek_trim <- dem_region(creek_sf, type = "trim") plot(creek_trim)
A glossary of flag terms
flags
flags
flags
A data frame with 10 rows and 2 columns:
flag name
Flag description
Clean and categorize lithology descriptions into primary, secondary, tertiary and final lithology categories. Generally this function is used internally when loading and cleaning GWELLS lithology.
lith_fix(file = "lithology.csv", desc = NULL)
lith_fix(file = "lithology.csv", desc = NULL)
file |
Character. Lithology file name stored in cache |
desc |
Character. Text string to convert (overrides |
However statements can be tested directly with this function to see how it works and for troubleshooting.
Data frame of lithology categorizations
lith_fix(desc = "sandy gravel") # basic spell checks lith_fix(desc = "saandy gravel")
lith_fix(desc = "sandy gravel") # basic spell checks lith_fix(desc = "saandy gravel")
A spatial data frame of map tiles with corresponding links to Lidar tiles.
tiles
tiles
tiles
A data frame with 7,129 rows and 5 columns:
Tile name
Spatial data
Projection
Lidar tile name
Link to Lidar tile
The spatial grid of map tiles is obtained from the BC Data Catalogue, BCGS 1:20,000 Grid
Links to Lidar tile urls are extracted from the list at the LidarBC Open LiDAR Data Portal
This function takes a region shape file and the DEM of a region (output of
dem_region()
), subsets the wells data (from GWELLS) to this region and adds
the elevation data.
wells_elev(wells_sub, dem, update = FALSE)
wells_elev(wells_sub, dem, update = FALSE)
wells_sub |
sf spatial data frame. Subset of wells data output by
|
dem |
stars simple features object. Output of |
update |
Logical. Force update of the data? |
sf spatial data frame
library(sf) library(ggplot2) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf) # Fetch Lidar DEM creek_lidar <- dem_region(creek_sf) # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_lidar) ggplot() + geom_sf(data = creek_sf) + geom_sf(data = creek_wells, aes(colour = elev), size = 0.5, fill = "NA", show.legend = FALSE) + coord_sf(datum = st_crs(3005)) # BC Albers # OR Fetch TRIM DEM creek_trim <- dem_region(creek_sf, type = "trim") # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_trim) ggplot() + geom_sf(data = creek_sf) + geom_sf(data = creek_wells, aes(colour = elev), size = 0.5, fill = "NA", show.legend = FALSE) + coord_sf(datum = st_crs(3005)) # BC Albers
library(sf) library(ggplot2) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf) # Fetch Lidar DEM creek_lidar <- dem_region(creek_sf) # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_lidar) ggplot() + geom_sf(data = creek_sf) + geom_sf(data = creek_wells, aes(colour = elev), size = 0.5, fill = "NA", show.legend = FALSE) + coord_sf(datum = st_crs(3005)) # BC Albers # OR Fetch TRIM DEM creek_trim <- dem_region(creek_sf, type = "trim") # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_trim) ggplot() + geom_sf(data = creek_sf) + geom_sf(data = creek_wells, aes(colour = elev), size = 0.5, fill = "NA", show.legend = FALSE) + coord_sf(datum = st_crs(3005)) # BC Albers
Export wells data for use in Strater and Voxler
wells_export(wells_sub, id, type, dir = ".", preview = FALSE)
wells_export(wells_sub, id, type, dir = ".", preview = FALSE)
wells_sub |
Data frame. Output of |
id |
Character. Id to prepend to all output files e.g., "id_lith.csv" |
type |
Character. Format in which to export. One of "strater", "voxler", "archydro", "leapfrog", or "surfer" (case-insensitive). |
dir |
Character. Directory where files should be exported to. Defaults to working directory. |
preview |
Logical. Whether to preview the exports ( |
If preview = FALSE
, a vector of file names, if preview = TRUE
,
a list of data frames.
library(sf) # Load a shape file defining the region of interest creek <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek) # Fetch Lidar DEM creek_lidar <- dem_region(creek) # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_lidar) # Preview data for Strater p <- wells_export(creek_wells, id = "clinton", type = "strater", preview = TRUE) names(p) p[["strater_lith"]] p[["strater_collars"]] p[["strater_wells"]] # Export data for Strater wells_export(creek_wells, id = "clinton", type = "strater") # Export Arc Hydro wells_export(creek_wells, id = "clinton", type = "archydro") # Export Surver wells_export(creek_wells, id = "clinton", type = "surfer")
library(sf) # Load a shape file defining the region of interest creek <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek) # Fetch Lidar DEM creek_lidar <- dem_region(creek) # Collect wells in this region with added elevation from Lidar creek_wells <- wells_elev(creek_wells, creek_lidar) # Preview data for Strater p <- wells_export(creek_wells, id = "clinton", type = "strater", preview = TRUE) names(p) p[["strater_lith"]] p[["strater_collars"]] p[["strater_wells"]] # Export data for Strater wells_export(creek_wells, id = "clinton", type = "strater") # Export Arc Hydro wells_export(creek_wells, id = "clinton", type = "archydro") # Export Surver wells_export(creek_wells, id = "clinton", type = "surfer")
Filter the GWELLS data returning only wells within the provided shapefile.
wells_subset(region, update = FALSE)
wells_subset(region, update = FALSE)
region |
sf simple features object. Shape file of the region of interest. |
update |
Logical. Force update of the data? |
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf)
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf)
Yield records are extracted from lithology observations and added to the wells data.
wells_yield(wells_sub)
wells_yield(wells_sub)
wells_sub |
sf spatial data frame. Subset of wells data output by
|
Data frame or sf spatial data frame with wells data and added yield from lithology.
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf) # Get yield data for these wells creek_yield <- wells_yield(creek_wells)
library(sf) # Load a shape file defining the region of interest creek_sf <- st_read("misc/data/Clinton_Creek.shp") # Get wells within this region creek_wells <- wells_subset(creek_sf) # Get yield data for these wells creek_yield <- wells_yield(creek_wells)