RStoolbox

Remote Sensing Data Analysis in R 🛰

https://github.com/bleutner/rstoolbox

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • â—‹
    CITATION.cff file
  • ✓
    codemeta.json file
    Found codemeta.json file
  • ✓
    .zenodo.json file
    Found .zenodo.json file
  • â—‹
    DOI references
  • â—‹
    Academic publication links
  • ✓
    Committers with academic emails
    2 of 12 committers (16.7%) from academic institutions
  • â—‹
    Institutional organization owner
  • â—‹
    JOSS paper metadata
  • â—‹
    Scientific vocabulary similarity
    Low similarity (17.7%) to scientific vocabulary

Keywords

cran ggplot2 land-cover-mapping r r-package remote-sensing spectral-unmixing supervised-classification unsupervised-classification
Last synced: 6 months ago · JSON representation

Repository

Remote Sensing Data Analysis in R 🛰

Basic Info
  • Host: GitHub
  • Owner: bleutner
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 211 MB
Statistics
  • Stars: 284
  • Watchers: 25
  • Forks: 85
  • Open Issues: 25
  • Releases: 17
Topics
cran ggplot2 land-cover-mapping r r-package remote-sensing spectral-unmixing supervised-classification unsupervised-classification
Created almost 12 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog

README.md

RStoolbox

CI CRAN version codecov Downloads StackOverflow

RStoolbox is an R package providing a wide range of tools for your every-day remote sensing processing needs. The available tool-set covers many aspects from data import, pre-processing, data analysis, image classification and graphical display. RStoolbox builds upon the terra package, which makes it suitable for processing large data-sets even on smaller workstations.

Find out more on the RStoolbox webpage.

Installation

The package is available on CRAN and can be installed as usual via

R install.packages("RStoolbox")

To install the latest version from GitHub you need to have r-base-dev (Linux) or Rtools (Windows) installed. Then run the following lines:

R library(devtools) install_github("bleutner/RStoolbox")

Get started

RStoolbox implements a variety of remote sensing methods and workflows. Below are a few examples to get started. Further examples can be found in the documentation of the respective functions.

Example 1: Classifications

The example below shows an unsupervised classification workflow based on kmeans clustering:

``` r library(RStoolbox)

unsupervised classification with 3 classes

uc <- unsuperClass(lsat, nClasses = 3)

plot result using ggplot

ggR(uc$map, geomraster = T, forceCat = T) + scalefill_manual(values = c("darkgreen", "blue", "sandybrown")) ```

<!-- -->

If training data are available, e.g. labeled polygons, RStoolbox can be used to conduct a supervised classification. The workflow below employs randomForest to train a classification model:

``` r library(RStoolbox) library(caret) library(randomForest) library(ggplot2) library(terra)

example: training data from digitized polygons

train <- readRDS(system.file("external/trainingPolygons_lsat.rds", package="RStoolbox"))

plot input data

ggRGB(lsat, r = 3, g = 2, b=1, stretch = "lin") + geomsf(data = train, aes(fill = class)) + scalefill_manual(values = c("yellow", "sandybrown", "darkgreen", "blue"))

> Coordinate system already present. Adding new coordinate system, which will

> replace the existing one.

```

<!-- -->

``` r

fit random forest (splitting training into 70\% training data, 30\% validation data)

sc <- superClass(lsat, trainData = train, responseCol = "class", model = "rf", tuneLength = 1, trainPartition = 0.7)

print model performance and confusion matrix

sc$modelFit

> [[1]]

> TrainAccuracy TrainKappa method

> 1 0.9992293 0.9988032 rf

>

> [[2]]

> Cross-Validated (5 fold) Confusion Matrix

>

> (entries are average cell counts across resamples)

>

> Reference

> Prediction cleared fallen_dry forest water

> cleared 141.6 0.0 0.0 0.0

> fallen_dry 0.0 22.0 0.0 0.0

> forest 0.4 0.0 255.0 0.0

> water 0.0 0.0 0.0 99.4

>

> Accuracy (average) : 0.9992

plotting: convert class IDs to class labels (factorize) and plot

r <- as.factor(sc$map) levels(r) <- data.frame(ID = 1:4, classsupervised = levels(train$class)) ggR(r, geomraster = T, forceCat = T) + scalefillmanual(values = c("yellow", "sandybrown", "darkgreen", "blue")) ```

<!-- -->

Created on 2024-04-19 with reprex v2.1.0

Example 2: Spectral Unmixing

RStoolbox offers spectral unmixing by implementing the Multiple Endmember Spectral Mixture Analysis (MESMA) approach for estimating fractions of spectral classes, such as spectra of surfaces or materials, on a sub-pixel scale. The following workflow shows a simple Spectral Mixture Analysis (SMA) with single endmembers per class, extracted from the lsat example image by cell id:

``` r library(RStoolbox) library(terra)

to perform a SMA, use a single endmember per class, row by row:

em <- data.frame(lsat[c(5294, 47916)]) rownames(em) <- c("forest", "water")

umix the lsat image

probs <- mesma(img = lsat, em = em) plot(probs) ```

<!-- -->

Instead, one can define multiple endmembers per class to conduct a Multiple Endmember Spectral Mixture Analysis (MESMA):

``` r library(RStoolbox) library(terra)

to perform a MESMA, use multiple endmembers per class, differntiating them

by a column named 'class':

em <- rbind( data.frame(lsat[c(4155, 17018, 53134, 69487, 83704)], class = "forest"), data.frame(lsat[c(22742, 25946, 38617, 59632, 67313)], class = "water") )

unmix the lsat image

probs <- mesma(img = lsat, em = em) plot(probs) ```

<!-- -->

``` r

MESMA can also be performed on more than two endmember classes:

em <- rbind( data.frame(lsat[c(4155, 17018, 53134, 69487, 83704)], class = "forest"), data.frame(lsat[c(22742, 25946, 38617, 59632, 67313)], class = "water"), data.frame(lsat[c(4330, 1762, 1278, 1357, 17414)], class = "shortgrown") )

unmix the lsat image

probs <- mesma(img = lsat, em = em) plot(probs) ```

<!-- -->

Example 3: Cloud Masking

RStoolbox comes with a suite of pre-processing functions, including cloudMask to identify clouds in optical satellite imagery:

``` r library(ggplot2)

lsat example scene, with two tiny clouds in the east

ggRGB(lsat, stretch = "lin") ```

<!-- -->

``` r

calculate cloud index

cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) ```

<!-- -->

``` r

mask by threshold, region-growing around the core cloud pixels

cldmsk_final <- cloudMask(cldmsk, threshold = 0.1, buffer = 5)

plot cloudmask

ggRGB(lsat, stretch = "lin") + ggR(cldmskfinal[[1]], ggLayer = TRUE, forceCat = TRUE, geomraster = TRUE) + scalefillmanual(values = c("red"), na.value = NA)

> Warning: Removed 88752 rows containing missing values or values outside the scale range

> (geom_raster()).

```

<!-- -->

Example 4: Radiometric and atmospheric correction

With radCor, users can compute radiometric and simple atmospheric corrections (based on dark object substraction):

``` r library(terra)

import Landsat meta data

mtlFile <- system.file("external/landsat/LT52240631988227CUB02MTL.txt", package="RStoolbox") metaData <- readMeta(mtlFile) lsatt <- stackMeta(mtlFile)

convert DN to top of atmosphere reflectance and brightness temperature

lsatref <- radCor(lsatt, metaData = metaData, method = "apref")

correct DN to at-surface-reflecatance with DOS (Chavez decay model)

lsatsref <- radCor(lsatt, metaData = metaData)

correct DN to at-surface-reflecatance with simple DOS and automatic haze estimation

hazeDN <- estimateHaze(lsatt, hazeBands = 1:4, darkProp = 0.01, plot = FALSE) lsatsref <- radCor(lsat_t, metaData = metaData, method = "sdos", hazeValues = hazeDN, hazeBands = 1:4)

plot result

ggRGB(lsat_sref, r = 3, g = 2, b = 1, stretch = "lin") ```

<!-- -->

Created on 2024-04-19 with reprex v2.1.0

Owner

  • Name: Benjamin Leutner
  • Login: bleutner
  • Kind: user
  • Location: Germany
  • Company: The Landbanking Group

remote sensing scientist, open source developer, spatial ecologist

GitHub Events

Total
  • Create event: 2
  • Issues event: 15
  • Release event: 3
  • Watch event: 23
  • Issue comment event: 25
  • Push event: 55
  • Pull request event: 6
  • Fork event: 1
Last Year
  • Create event: 2
  • Issues event: 15
  • Release event: 3
  • Watch event: 23
  • Issue comment event: 25
  • Push event: 55
  • Pull request event: 6
  • Fork event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 828
  • Total Committers: 12
  • Avg Commits per committer: 69.0
  • Development Distribution Score (DDS): 0.319
Past Year
  • Commits: 34
  • Committers: 1
  • Avg Commits per committer: 34.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
bleutner b****r@u****e 564
Konstantin k****r@g****e 107
Benjamin Leutner b****r@d****e 81
16EAGLE j****w@w****e 30
KonstiDE k****1@g****e 17
Konstantin k****9@g****e 13
myname n****t@m****l 7
Martin Wegmann m****n@r****g 4
nedhorning h****g@a****g 2
jjarosch j****h@t****e 1
Neal Fultz n****z@g****m 1
Mervin Fansler f****m@m****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 100
  • Total pull requests: 24
  • Average time to close issues: 8 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 63
  • Total pull request authors: 9
  • Average comments per issue: 2.45
  • Average comments per pull request: 0.79
  • Merged pull requests: 20
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 9
  • Pull requests: 3
  • Average time to close issues: 4 months
  • Average time to close pull requests: less than a minute
  • Issue authors: 8
  • Pull request authors: 1
  • Average comments per issue: 1.33
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • aloboa (13)
  • bleutner (6)
  • Daliben (5)
  • Saadi4469 (5)
  • bappa10085 (4)
  • topepo (3)
  • ailich (3)
  • rsbivand (3)
  • iqbalhabibie (2)
  • andliszmmu (2)
  • Romaysa (2)
  • MarkusMartini (1)
  • grace747 (1)
  • clearclar (1)
  • nealresearch (1)
Pull Request Authors
  • KonstiDE (18)
  • 16EAGLE (6)
  • mfansler (2)
  • FabrizioSandri (1)
  • Martin-Jung (1)
  • jjarosch (1)
  • nedhorning (1)
  • rsbivand (1)
  • nfultz (1)
Top Labels
Issue Labels
feature request (8) bug (6) enhancement (1)
Pull Request Labels

Packages

  • Total packages: 4
  • Total downloads:
    • cran 1,505 last-month
  • Total dependent packages: 7
    (may contain duplicates)
  • Total dependent repositories: 13
    (may contain duplicates)
  • Total versions: 57
  • Total maintainers: 1
cran.r-project.org: RStoolbox

Remote Sensing Data Analysis

  • Versions: 22
  • Dependent Packages: 7
  • Dependent Repositories: 13
  • Downloads: 1,505 Last month
Rankings
Forks count: 1.0%
Stargazers count: 2.0%
Average: 4.5%
Dependent packages count: 6.8%
Dependent repos count: 8.3%
Last synced: 6 months ago
proxy.golang.org: github.com/bleutner/rstoolbox
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/bleutner/RStoolbox
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: r-rstoolbox
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 19.6%
Stargazers count: 23.2%
Average: 32.0%
Dependent repos count: 34.0%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

.github/workflows/coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/rcmdcheck.yaml actions
  • actions/checkout v2 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
DESCRIPTION cran
  • R >= 3.5.0 depends
  • Rcpp * imports
  • XML * imports
  • caret >= 6.0 imports
  • codetools * imports
  • doParallel * imports
  • dplyr * imports
  • exactextractr * imports
  • foreach * imports
  • ggplot2 * imports
  • lifecycle * imports
  • methods * imports
  • parallel * imports
  • raster >= 2.3 imports
  • reshape2 * imports
  • rgdal * imports
  • sf * imports
  • sp * imports
  • terra * imports
  • e1071 * suggests
  • gridExtra * suggests
  • kernlab * suggests
  • pls * suggests
  • randomForest * suggests
  • testthat * suggests