rOPTRAM
Implements The OPtical TRapezoid Model (OPTRAM) to derive soil moisture based on the linear relation between a vegetation index, i.e. NDVI, and Shortwave Infra-red.
https://github.com/ropensci/roptram
Category: Natural Resources
Sub Category: Soil and Land
Keywords from Contributors
geocoding
Last synced: about 5 hours ago
JSON representation
Repository metadata
Derive Soil Moisture Using the OPTRAM Algorithm
- Host: GitHub
- URL: https://github.com/ropensci/roptram
- Owner: ropensci
- License: gpl-3.0
- Created: 2024-06-06T12:46:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-21T09:45:45.000Z (about 1 month ago)
- Last Synced: 2025-04-22T07:48:00.357Z (9 days ago)
- Language: R
- Homepage: https://docs.ropensci.org/rOPTRAM/
- Size: 59.5 MB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 4
- Releases: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codemeta: codemeta.json
README.Rmd
--- output: github_document bibliography: vignettes/references.bib --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) ``` # rOPTRAM[](https://www.repostatus.org/#active) [](https://github.com/ropensci/rOPTRAM/actions/workflows/R-CMD-check.yaml) [](https://zenodo.org/doi/10.5281/zenodo.13257766) [](https://doi.org/10.21105/joss.07086) `rOPTRAM` implements The OPtical TRapezoid Model (OPTRAM) to derive soil moisture based on the linear relation between a vegetation index, i.e. NDVI, and Shortwave Infra-red (SWIR). The SWIR band is transformed to SWIR Transformed Reflectance (STR). A scatterplot of NDVI vs. STR is used to produce wet and dry linear regression lines, and the slope/intercept coefficients of these lines comprise the trapezoid. These coefficients are then used on a new satellite image to determine soil moisture. See: @sadeghi_optical_2017, @burdun_satellite_2020, @ambrosone_retrieving_2020 ## Installation `rOPTRAM` resides on github. You can install the development version of rOPTRAM like so: ``` {r install, eval=FALSE} # Install remotes package if (! require("remotes")) { install.packages("remotes") } remotes::install_github("ropensci/rOPTRAM") ``` #### Prerequisites Only a small number of commonly used R packages are required to use {rOPTRAM}. This includes: - base packages {tools} and {utils} - spatial packages {sf} and {terra} - data.frame and plotting {dplyr}, {ggplot2}, {MASS} Users can download Sentinel-2 tiles from the Copernicus manually, and run thru the steps to produce the OPTRAM trapezoid, and predicted soil moisture maps. However, this approach is not optimal. By installing a few additional packages, the workflow can be initiated by a single function call to download, clip to area of interest, and produce the trapezoid coefficients. The all-inclusive approach is highly recommended since processing of the Sentinel-2 data is performed "in the cloud" and only the final products are downloaded, **greatly** reducing the download file sizes. To run the all-inclusive approach, the first step of acquiring Sentinel-2 imagery is handled by the R package {CDSE}. (see @karaman_cdse_2023). The {jsonlite} package is also necessary. That R package interfaces with the Copernicus DataSpace Ecosystem in one of two ways: - Thru the [Scihub API](https://shapps.dataspace.copernicus.eu/dashboard/#/). - Thru the [openEO platform](https://openeo.dataspace.copernicus.eu/) Both methods require [registering](https://dataspace.copernicus.eu/) on the Copernicus DataSpace ## Available functions #### optram_options() Several package options are defined, with default values, when {rOPTRAM} first loads. Each of these can be set individually to user chosen values. For example, the package uses a vegetation index (compared to SWIR Transformed Reflectance) values to plot the trapezoid. The default index is "NDVI". In a low vegetation, arid region, users can choose an alternative such as "SAVI" (see example below). The default maximum cloud cover is set to 12 [%], and users can choose any value between 0-100. #### optram() A main wrapper function to run the whole OPTRAM procedure. This function performs the following steps: - Acquire Sentinel 2 images covering the requested date range, and clipped to the input area of interest. This step relies on the {CDSE} package - Create the set of SWIR Transformed Reflectance (STR) rasters; - Prepare a dataframe of NDVI and STR values for all pixels from all images; - Calculate the trapezoid wet and dry regression lines, and save coefficients to a CSV file. Returns: RMSE values of the fitted regression lines of the trapezoid. #### optram_acquire_s2() Acquire Sentinel 2 images covering the requested date range, and clipped to the input area of interest. Among the function parameters, the `method` can be specified as either "scihub" or "openeo", thus choosing one of the two available acqquistion methods. Returns: a list of downloaded Sentinel 2 images #### optram_calculate_str() Extracts the required bands and prepares the vegetation index and SWIR transformed reflectance. #### optram_ndvi_str() Collects all pixel values from both the vegetation index and STR rasters, for all acquisition dates, and saves into a data.frame Returns: the full data.frame #### optram_wetdry_coefficients() Calculates the wet-dry trapezoid from the data.frame of NDVI and STR values, and obtains regression slope and intercept for both lines Three possible fitting methods are offered in this function, thru the "trapezoid_method" parameter. The user can choose to match the upper (wet) and lower (dry) bounds of the trapezoid either as a linear regression line, an exponential curve, or a second order polynomial function. Returns: the set of four (or six, in the case of polynomial curve) coefficients. #### optram_calculate_soil_moisture() Calculates soil moisture rasters for a time series of images, using the OPTRAM model coefficients from above procedure. #### optram_landsat() Prepares the OPTRAM coefficients from a time series of Landsat images, (instead of Sentinel). This function requires that the images are downloaded in advance. Returns: the set of four coefficients. #### optram_safe() In case Sentinel images have been downloaded in advance, this function prepares the STR and NDVI rasters, then calculate the trapezoid regression coefficients. It requires an input directory containing the Sentinel 2 images in the original SAFE file format. ## Example First, a demonstration of choosing non-default package options. ```{r options} # Show default options rOPTRAM::optram_options() # Change one options rOPTRAM::optram_options("veg_index", "SAVI", show_opts = FALSE) ``` Next a basic example which shows how to: - retrieve Sentinel 2 imagery for a specific area of interest - covering a date range - preprocess the imagery to obtain a vegetation index and STR band - use these to derive coefficients of slope and intercept for the OPTRAM trapezoid - using the "linear" fitting method ```{r example, eval=FALSE} library(rOPTRAM) # basic example aoi <- sf::st_read(system.file("extdata", "lachish.gpkg", package="rOPTRAM")) rmse <- rOPTRAM::optram( aoi = aoi, from_date = "2021-01-01", to_date = "2021-03-30", max_cloud = 10) print(rmse) ``` ## Note In order to download Sentinel 2 images, the {CDSE} package is used: (@karaman_cdse_2023) That package should be installed in advance in order to run the `optram()` wrapper function. If, on the other hand, Sentinel 2 imagery has been downloaded in advance, then {CDSE} is not strictly necessary. Instead, the following workflow can be used: - call `optram_safe()` to prepare NDVI and STR rasters - call `optram_calculate_str()` to calculate SWIR Transform - call `optram_ndvi_str()` to build a data.frame of pixel values - call `optram_wetdry_coefficients()` to derive slope and intercept of the trapezoid. ## Meta - Please report any issues on [github](https://github.com/ropensci/rOPTRAM/issues) - Anyone interested in collaborating is invited to "sign up" by contacting the maintainers. - This package is released with a [Contributor Code of Conduct](https://github.com/ropensci/.github/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
Owner metadata
- Name: rOpenSci
- Login: ropensci
- Email: info@ropensci.org
- Kind: organization
- Description:
- Website: https://ropensci.org/
- Location: Berkeley, CA
- Twitter: rOpenSci
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1200269?v=4
- Repositories: 307
- Last ynced at: 2023-03-10T20:30:59.242Z
- Profile URL: https://github.com/ropensci
GitHub Events
Total
- Issues event: 4
- Watch event: 3
- Delete event: 2
- Issue comment event: 5
- Push event: 14
- Create event: 1
Last Year
- Issues event: 4
- Watch event: 3
- Delete event: 2
- Issue comment event: 5
- Push event: 14
- Create event: 1
Committers metadata
Last synced: 1 day ago
Total Commits: 720
Total Committers: 4
Avg Commits per committer: 180.0
Development Distribution Score (DDS): 0.051
Commits in past year: 117
Committers in past year: 2
Avg Commits per committer in past year: 58.5
Development Distribution Score (DDS) in past year: 0.009
Name | Commits | |
---|---|---|
Micha Silver | s****m@p****l | 683 |
Ron Beiden | 1****n | 31 |
Natalya | n****6@g****m | 5 |
Maëlle Salmon | m****n@y****e | 1 |
Committer domains:
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 4
Total pull requests: 2
Average time to close issues: 4 days
Average time to close pull requests: about 2 hours
Total issue authors: 4
Total pull request authors: 1
Average comments per issue: 1.5
Average comments per pull request: 0.5
Merged pull request: 1
Bot issues: 0
Bot pull requests: 0
Past year issues: 4
Past year pull requests: 2
Past year average time to close issues: 4 days
Past year average time to close pull requests: about 2 hours
Past year issue authors: 4
Past year pull request authors: 1
Past year average comments per issue: 1.5
Past year average comments per pull request: 0.5
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- micha-silver (1)
- maelle (1)
- javimarlop (1)
- kiviarttu (1)
Top Pull Request Authors
- maelle (2)
Top Issue Labels
- documentation (1)
Top Pull Request Labels
Dependencies
- R >= 4.1.0 depends
- dplyr * imports
- ggplot2 * imports
- sf * imports
- terra * imports
- utils * imports
- CDSE * suggests
- geojsonio * suggests
- jsonlite * suggests
- knitr * suggests
- lwgeom * suggests
- openeo * suggests
- qpdf * suggests
- rmarkdown * suggests
- stats * suggests
- testthat >= 3.0.0 suggests
- xml2 * suggests
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
Score: 4.025351690735149