Giter Club home page Giter Club logo

hwsdr's Introduction

hwsdr

R-CMD-check codecov CRAN_Status_Badge downloads DOI

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.

How to cite this package in your article

Koen Hufkens. (2022). bluegreen-labs/hwsdr: CRAN release (v1.0). Zenodo. https://doi.org/10.5281/zenodo.6527648

Installation

stable release

To install the current stable release use a CRAN repository:

install.packages("hwsdr")
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:

if(!require(remotes)){install.packages("remotes")}
remotes::install_github("bluegreen-labs/hwsdr")
library("hwsdr")

Vignettes are not rendered by default, if you want to include additional documentation please use:

if(!require(remotes)){install.packages("remotes")}
remotes::install_github("bluegreen-labs/hwsdr", build_vignettes = TRUE)
library("hwsdr")

Use

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.

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

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).

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

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.

# 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.

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 (%).

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

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).

hwsdr's People

Contributors

khufkens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hwsdr's Issues

Please remove dependencies on **rgdal**, **rgeos**, and/or **maptools**

This package depends on (depends, imports or suggests) raster and one or more of the retiring packages rgdal, rgeos or maptools (https://r-spatial.org/r/2022/04/12/evolution.html, https://r-spatial.org/r/2022/12/14/evolution2.html). Since raster 3.6.3, all use of external FOSS library functionality has been transferred to terra, making the retiring packages very likely redundant. It would help greatly if you could remove dependencies on the retiring packages as soon as possible.

Queries resulting in all NAs

This looks like a great package! I have tried installing both the stable CRAN and development release versions of hwsdr. WIth either loaded, when I then try to run the first line of example code ...

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

... I get NAs across the board:

> all
   site  parameter latitude longitude value
1  HWSD         ID   -81.05     33.95     1
2  HWSD  AWC_CLASS   -81.05     33.95    NA
3  HWSD     ISSOIL   -81.05     33.95    NA
4  HWSD  MU_GLOBAL   -81.05     33.95    NA
5  HWSD  REF_DEPTH   -81.05     33.95    NA
6  HWSD      ROOTS   -81.05     33.95    NA
7  HWSD T_BULK_DEN   -81.05     33.95    NA
8  HWSD S_BULK_DEN   -81.05     33.95    NA
9  HWSD T_REF_BULK   -81.05     33.95    NA
10 HWSD S_REF_BULK   -81.05     33.95    NA
11 HWSD T_CEC_CLAY   -81.05     33.95    NA
12 HWSD S_CEC_CLAY   -81.05     33.95    NA
13 HWSD     T_CLAY   -81.05     33.95    NA
14 HWSD     S_CLAY   -81.05     33.95    NA
15 HWSD   T_GRAVEL   -81.05     33.95    NA
16 HWSD   S_GRAVEL   -81.05     33.95    NA
17 HWSD     T_SAND   -81.05     33.95    NA
18 HWSD     S_SAND   -81.05     33.95    NA
19 HWSD     T_SILT   -81.05     33.95    NA
20 HWSD     S_SILT   -81.05     33.95    NA
21 HWSD   T_PH_H2O   -81.05     33.95    NA
22 HWSD   S_PH_H2O   -81.05     33.95    NA
23 HWSD        t_c   -81.05     33.95    NA
24 HWSD        s_c   -81.05     33.95    NA
25 HWSD       T_OC   -81.05     33.95    NA
26 HWSD       S_OC   -81.05     33.95    NA
27 HWSD  SUM_s_c_1   -81.05     33.95    NA
28 HWSD SUM_t_c_12   -81.05     33.95    NA

Here is my session info:

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] hwsdr_1.1

loaded via a namespace (and not attached):
 [1] desc_1.4.3         R6_2.5.1           codetools_0.2-19   magrittr_2.0.3     e1071_1.7-14       remotes_2.4.2.1    KernSmooth_2.23-22
 [8] classInt_0.4-10    sf_1.0-16          ps_1.7.6           cli_3.6.2          processx_3.8.4     callr_3.7.6        grid_4.3.2        
[15] DBI_1.2.2          terra_1.7-71       proxy_0.4-27       class_7.3-22       compiler_4.3.2     httr_1.4.7         rstudioapi_0.15.0 
[22] tools_4.3.2        pkgbuild_1.4.3     curl_5.2.1         Rcpp_1.0.12        units_0.8-5       

CRAN release (v1.1)

prepare for release:

  • Check CRAN issues
  • urlchecker::url_check()
  • devtools::check(document = FALSE)
  • rhub::check_for_cran()
  • Update cran-comments.md
  • Update NEWS.md
  • git push

Submit to CRAN:

  • devtools::submit_cran()
  • Approve email
  • Accepted email

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.