Skip to content

Commit

Permalink
Merge pull request #7 from bluegreen-labs/patch-hwsd-v2
Browse files Browse the repository at this point in the history
correct reference
  • Loading branch information
khufkens authored Aug 7, 2023
2 parents dc1cfe5 + 8a35ac7 commit 04ab742
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 16 deletions.
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ library("hwsdr")

### development release

> Breaking change: as of version 1.1 the order of the coordinates in the
location string has changed from (lat, lon, lat, lon) to (lon, lat, lon, lat)!

To install the development releases of the package run the following
commands:

Expand All @@ -45,39 +48,88 @@ library("hwsdr")

## Use

### Single pixel location download
### HWSD v1.2 (ORNL DAAC API)

#### Single pixel location download

Get world soil values for a single site using the following format, specifying coordinates as a pair of latitude, longitude coordinates. Here all available soil layers are queried.

``` r
all <- ws_subset(
all <- ws_subset(
site = "HWSD",
location = c(34, -81),
param = "ALL"
)
```

### Gridded data
#### Gridded data

You can download gridded data by specifying a bounding box c(lat, lon, lat, lon) defined by a bottom left and top right coordinates. Here the call only extracts the top soil fraction of sand (% weight).

``` r
t_sand <- ws_subset(
t_sand <- ws_subset(
site = "HWSD",
location = c(32, -81, 34, -80),
param = "T_SAND",
path = tempdir(),
internal = TRUE
)
```
## Parameters
### Parameters

By default all parameters are downloaded, a complete list of the individual parameters is provided on the ORNL webpage (<https://daac.ornl.gov/SOILS/guides/HWSD.html>). Alternatively you may find a similar list of data in the `hwsd_meta_data` dataset as provided by the package.

### HWSD v2.0 (FAO)

This is an experimental feature, awaiting an update of the ORNL DAAC API to version 2.0 of the HWSD database. Although functionally complete the procedure is more complex as it includes a bulk download of a base map.

#### Download the base map

The HWSD v2.0 data is distributed as a gridded spatial map where homogeneous regions are indicated with indices (integers). Although the underlying database is included in the package and can be accessed using `hwsdr::hwsd2`, the spatial data accompanying the database is too large for inclusion in the package. This spatial data needs to be downloaded explicitly to a desired path before any other functions will work.

```{r eval = FALSE}
# set the ws_path variable using a FULL path name
path <- ws_download(
ws_path = "/your/full/path",
verbose = TRUE
)
```

### Single pixel location download

Get world soil values for a single site using the following format, specifying coordinates as a pair of longitude, latitude coordinates (longitude, latitude). Here the call only extracts the top soil (layer = "D1") fraction of sand and silt (% weight) for one specific location. Note that you will need to specify the correct version to be used in processing.

```{r eval = FALSE}
values <- ws_subset(
site = "HWSD_V2",
location = c(-81, 34),
param = c("SAND","SILT"),
layer = "D1",
version = "2.0", # set correct HWSD version
ws_path = "/your/full/path" # specify grid map directory
)
```

### Gridded data

You can grab gridded data by specifying a bounding box c(lon, lat, lon, lat) defined by a bottom left and top right coordinates. Here the call only extracts the top soil (D1 layer) fraction of sand (%).

```{r eval = FALSE}
sand <- ws_subset(
location = c(32, -81, 34, -80),
param = "SAND",
layer = "D1",
version = "2.0",
ws_path = Sys.getenv("WS_PATH"),
# ws_path = "/your/full/path",
internal = TRUE
)
```

## References

Wieder, W.R., J. Boehnert, G.B. Bonan, and M. Langseth. 2014. Regridded Harmonized World Soil Database v1.2. Data set. Available on-line from Oak Ridge National Laboratory Distributed Active Archive Center, Oak Ridge, Tennessee, USA. (<https://daac.ornl.gov/cgi-bin/dsviewer.pl?ds_id=1247>).

## Acknowledgements

This project was supported by the Schmidt Futures Initiative Land Ecosystem Models based On New Theory, obseRvations, and ExperimEnts (LEMONTREE) project.
The `hwsdr` package is a product of BlueGreen Labs, and has been in part supported by the LEMONTREE project funded through the Schmidt Futures fund, under the umbrella of the Virtual Earth System Research Institute (VESRI).
20 changes: 10 additions & 10 deletions vignettes/hwsdr-v2-vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Although the package provides support for the programmatic interface to the Harm

### Download the base map

The HWSD v2.0 data is distributed as a spatial map where homogenous regions are indicated with indices (integers). Although the underlying database is included in the package and can be accessed using `hwsdr::hwsd2`, the spatial data accompanying the database is too large for inclusion in the package. This spatial data needs to be downloaded explicitly.
The HWSD v2.0 data is distributed as a spatial map where homogeneous regions are indicated with indices (integers). Although the underlying database is included in the package and can be accessed using `hwsdr::hwsd2`, the spatial data accompanying the database is too large for inclusion in the package. This spatial data needs to be downloaded explicitly.

Ideally, to speed up processing between sessions you download the data to a fixed location (directory) on your computer. The function `ws_download()` will download the data there. If successful the function will return the path where the data is located.

Expand Down Expand Up @@ -79,13 +79,13 @@ Get world soil values for a single site using the following format, specifying c

```{r eval = FALSE}
values <- ws_subset(
site = "HWSD_V2",
location = c(-81, 34),
param = c("SAND","SILT"),
layer = "D1",
version = "2.0",
ws_path = "/your/full/path"
)
site = "HWSD_V2",
location = c(-81, 34),
param = c("SAND","SILT"),
layer = "D1",
version = "2.0",
ws_path = "/your/full/path"
)
```

At this location we have a top soil fraction of sand of 78% weight and a silt fraction of 12 % weight! Data are returned as tidy data frames including basic meta-data of the query for later subsetting.
Expand All @@ -99,8 +99,8 @@ print(values)
You can grab gridded data by specifying a bounding box c(lon, lat, lon, lat) defined by a bottom left and top right coordinates. Here the call only extracts the top soil (D1 layer) fraction of sand (%).

```{r eval = FALSE}
sand <- ws_subset(
ws_subset(
sand <- ws_subset(
location = c(-81, 32, -80, 34),
param = "SAND",
layer = "D1",
version = "2.0",
Expand Down

0 comments on commit 04ab742

Please sign in to comment.