Title: | Interface to the 'HWSD' Web Services |
---|---|
Description: | Programmatic interface to the Harmonized World Soil Database 'HWSD' web services (<https://daac.ornl.gov/cgi-bin/dsviewer.pl?ds_id=1247>). Allows for easy downloads of 'HWSD' soil data directly to your R workspace or your computer. Routines for both single pixel data downloads and gridded data are provided. |
Authors: | Koen Hufkens [aut, cre] , BlueGreen Labs [cph, fnd] |
Maintainer: | Koen Hufkens <[email protected]> |
License: | AGPL-3 |
Version: | 1.1 |
Built: | 2024-11-24 04:39:57 UTC |
Source: | https://github.com/bluegreen-labs/hwsdr |
Data frame with meta-data on the ORNL DAAC parameters one can query using the THREDDS server. In addition a brief description of the various data products and their units is provided.
hwsd_meta_data
hwsd_meta_data
data.frame
parameter names used in THREDDS server call
bands within a data product (only for CLM data)
general description of the variable
units of the variable
Database holding the full HWSD v2.0 database layer information for the main soil type specified. For the fields included (i.e. the column names I refer to the FAO documentation).
hwsd2
hwsd2
data.frame
Downloads both the database and gridded HWSD v2.0 data products to a desired output path for subsetting.
ws_download(ws_path = file.path(tempdir(), "ws_db"), verbose = FALSE)
ws_download(ws_path = file.path(tempdir(), "ws_db"), verbose = FALSE)
ws_path |
the path / directory where to store the HWSD v2.0 database |
verbose |
verbose messaging of downloading and managing the gridded data file |
When an existing path is used which is not the temporary directory an environmental variable WS_PATH can be set by creating an ~/.Renviron file using usethis::edit_r_environ() and entering the path as:
WS_PATH = "/your/full/path"
This variable will override the default temporary directory if it exists. This allows the gridded data to be stored elsewhere and be forgotten (while using the hwsdr package for HWSD v2.0).
Should you delete the gridded file, the environmental variable should be altered and set again by editting the ~/.Renviron file to a new location.
current data path
## Not run: # Download the gridded soil map of # HWSD v2.0 to the temporary directory ws_download() # download the same data to a specific # directory (which should exist) ws_download( ws_path = "~/my_path" ) # download the same data to a specific # directory (which should exist) and # update the environmental variable ws_download( ws_path = "~/my_path", verbose = TRUE ) ## End(Not run)
## Not run: # Download the gridded soil map of # HWSD v2.0 to the temporary directory ws_download() # download the same data to a specific # directory (which should exist) ws_download( ws_path = "~/my_path" ) # download the same data to a specific # directory (which should exist) and # update the environmental variable ws_download( ws_path = "~/my_path", verbose = TRUE ) ## End(Not run)
Downloads HWSD data, wrapped by ws_subset()
for convenient use. This is a
function mainly for internal use but exposed so people can benefit from
it in other (more flexible) setups if so desired.
ws_get(location, param, path, internal = TRUE)
ws_get(location, param, path, internal = TRUE)
location |
file with several site locations and coordinates in a comma delimited format: site, latitude, longitude |
param |
which soil parameter to use |
path |
default is tempdir() |
internal |
return an internal raster or just retain values in the path |
HWSD data as a raster file
Subset function to query pixel or spatial data from the ORNL DAAC HWSD THREDDS server. Returns a tidy data frame for point locations or raster data to the workspace or disk.
ws_subset( location = c(32, -81, 34, -80), site = "HWSD", param = "ALL", layer = "D1", path = tempdir(), ws_path = file.path(tempdir(), "ws_db"), internal = TRUE, rate = 0.1, version = 1.2, verbose = FALSE )
ws_subset( location = c(32, -81, 34, -80), site = "HWSD", param = "ALL", layer = "D1", path = tempdir(), ws_path = file.path(tempdir(), "ws_db"), internal = TRUE, rate = 0.1, version = 1.2, verbose = FALSE )
location |
location of a bounding box c(lon, lat, lon, lat) defined by a bottom-left and top-right coordinates, a single location (lon, lat) |
site |
sitename for the extracted location |
param |
soil parameters to provide, the default setting is ALL, this will download all available soil parameters.Check https://daac.ornl.gov/SOILS/guides/HWSD.html for parameter descriptions. |
layer |
which soil depth layer of HWSD v2.0 to consider, layers are named D1 to D7 from top to bottom |
path |
path where to download the data to (only applicable to spatial data) |
ws_path |
path to the gridded HWSD v2.0 data, only required/used if querying v2.0 data |
internal |
do not store the data on disk |
rate |
request rate in seconds, determines how long to wait between queries to avoid bouncing because of rate limitations |
version |
version of HWSD to query (numeric value). By default the package will query the ORNL DAAC v1.2 via their API. If specifying the later version (2.0) it will download or require the gridded spatial data in addition to the included HWSD v2.0 database with soil parameters. |
verbose |
verbose output during processing, only covers the internal use of the ws_download() function for HWSD v2.0 data |
Local geotiff data, or a data frame with HWSD soil information
## Not run: # extract sand fraction values # for a point location values <- ws_subset( site = "HWSD", location = c(34, -81), param = "T_SAND" ) print(values) # Download a soil fraction map # of sand for a given bounding box t_sand <- ws_subset( site = "HWSD", location = c(32, -81, 34, -80), param = "T_SAND", path = tempdir(), internal = TRUE ) terra::plot(t_sand) ## End(Not run)
## Not run: # extract sand fraction values # for a point location values <- ws_subset( site = "HWSD", location = c(34, -81), param = "T_SAND" ) print(values) # Download a soil fraction map # of sand for a given bounding box t_sand <- ws_subset( site = "HWSD", location = c(32, -81, 34, -80), param = "T_SAND", path = tempdir(), internal = TRUE ) terra::plot(t_sand) ## End(Not run)