+
RStoolbox 1.0.1
+Changes for publication in MEE
+
+
+New:
+-
+
spectralIndices()
can now be customized. We made the indices available as an editable option in the RStoolbox package as suggested by a reviewer. Users now can append a custom index to it that will be then calculated via the C++ plus within spectralIndices.cpp.
+
+
+Changes:
+-
+
mesma()
now does not throw an error anymore when given no models and the default value was too high
+
RStoolbox 1.0.0
CRAN release: 2024-04-25
-Updating MESMA, minor changes before major release
+Minor changes before major release
New:
-
@@ -47,19 +61,6 @@
Changes:
RStoolbox 0.4.0
CRAN release: 2024-01-17
Rewrite of
-RStoolbox
, migration fromraster
toterra
andsp
tosf
--New:
-- RStoolbox moved on from the outdated
sp
andraster
packages tosf
andterra
to ensure long term support of the tools.
- - Thrown out unnecessary libraries -
-Fixes:
--
-
rasterPCA()
: Fixed a bug that caused the method and its unit tests to fail on Linux due to a corrupted covariance matrix calculated previously withterra::layerCor()
-
- -
-
superClass()
unable to predict when there is NA in raster data (closes #102, reported by @bappa10085)
-
- RStoolbox moved on from the outdated
RStoolbox 0.3.0
CRAN release: 2022-03-07
diff --git a/pkgdown.yml b/pkgdown.yml index 253cff9..7788041 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.1.1 pkgdown_sha: ~ articles: {} -last_built: 2024-10-23T15:21Z +last_built: 2024-10-23T15:31Z urls: reference: https://bleutner.github.io/RStoolbox/reference article: https://bleutner.github.io/RStoolbox/articles diff --git a/reference/ImageMetaData.html b/reference/ImageMetaData.html index 00f0c37..d272725 100644 --- a/reference/ImageMetaData.html +++ b/reference/ImageMetaData.html @@ -26,7 +26,7 @@RStoolbox: A Collection of Remote Sensing Tools
- Source:R/RStoolbox-package.R
+ Source: R/RStoolbox-package.R
RStoolbox.Rd
Cloud Shadow Masking for Flat Terrain
- Source:R/cloudMask.R
+ Source: R/cloudMask.R
cloudShadowMask.Rd
Image to Image Co-Registration based on Mutual Information
- Source:R/coregisterImages.R
+ Source: R/coregisterImages.R
coregisterImages.Rd
Estimate Image Haze for Dark Object Subtraction (DOS)
- Source:R/estimateHaze.R
+ Source: R/estimateHaze.R
estimateHaze.Rd
Fortify method for classes from the terra package.
- Source:R/fortify-raster.R
+ Source: R/fortify-raster.R
fortifySpatRaster.Rd
Extract bandwise information from ImageMetaData
- Source:R/getMeta.R
+ Source: R/getMeta.R
getMeta.Rd
Extract validation results from superClass objects
- Source:R/getValidation.R
+ Source: R/getValidation.R
getValidation.Rd
Create ggplot2 Raster Plots with RGB from 3 RasterLayers
- Source:R/ggRGB.R
+ Source: R/ggRGB.R
ggRGB.Rd
Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing)
- Source:R/mesma.R
+ Source: R/mesma.R
mesma.Rd
Normalize Raster Images: Center and Scale
- Source:R/normImage.R
+ Source: R/normImage.R
normImage.Rd
One-hot encode a raster or vector
- Source:R/oneHotEncode.R
+ Source: R/oneHotEncode.R
oneHotEncode.Rd
Pseudo-Invariant Features based Image Matching
- Source:R/pifMatch.R
+ Source: R/pifMatch.R
pifMatch.Rd
Predict a raster map based on a unsuperClass model fit.
- Source:R/unsuperClass.R
+ Source: R/unsuperClass.R
predict.unsuperClass.Rd
Principal Component Analysis for Rasters
- Source:R/rasterPCA.R
+ Source: R/rasterPCA.R
rasterPCA.Rd
Tidy import tool for EarthExplorer .csv export files
- Source:R/readEE.R
+ Source: R/readEE.R
readEE.Rd
Save and Read RStoolbox Classification Results
- Source:R/saveRSTBX.R
+ Source: R/saveRSTBX.R
saveRSTBX.Rd
Examples## Convert DNs to reflectance (required to calculate EVI and EVI2)
mtlFile <- system.file("external/landsat/LT52240631988227CUB02_MTL.txt", package="RStoolbox")
lsat_ref <- radCor(lsat, mtlFile, method = "apref")
-#> 15:22:27 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn
-#> 15:22:27 | Thermal bands to convert to brightness temperature: B6_dn
-#> 15:22:27 | Processing thermal band(s)
-#> 15:22:27 | Processing radiance / reflectance
+#> 15:32:01 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn
+#> 15:32:01 | Thermal bands to convert to brightness temperature: B6_dn
+#> 15:32:01 | Processing thermal band(s)
+#> 15:32:01 | Processing radiance / reflectance
SI <- spectralIndices(lsat_ref, red = "B3_tre", nir = "B4_tre")
plot(SI)
diff --git a/reference/srtm.html b/reference/srtm.html
index 5eadc12..21c45c5 100644
--- a/reference/srtm.html
+++ b/reference/srtm.html
@@ -26,7 +26,7 @@
SRTM Digital Elevation Model
- Source: R/RStoolbox-package.R
+ Source: R/RStoolbox-package.R
srtm.Rd
diff --git a/reference/srtm_sen2.html b/reference/srtm_sen2.html
index d0ba9b6..ac5dfc4 100644
--- a/reference/srtm_sen2.html
+++ b/reference/srtm_sen2.html
@@ -26,7 +26,7 @@
SRTM scene for the sen2 exemplary scene
- Source: R/RStoolbox-package.R
+ Source: R/RStoolbox-package.R
srtm_sen2.Rd
diff --git a/reference/stackMeta.html b/reference/stackMeta.html
index 7cfea9d..24c5aaa 100644
--- a/reference/stackMeta.html
+++ b/reference/stackMeta.html
@@ -28,7 +28,7 @@
Import separate Landsat files into single stack
- Source: R/stackMeta.R
+ Source: R/stackMeta.R
stackMeta.Rd
diff --git a/reference/superClass.html b/reference/superClass.html
index 2e41237..7acbe6e 100644
--- a/reference/superClass.html
+++ b/reference/superClass.html
@@ -26,7 +26,7 @@
@@ -211,10 +211,10 @@ Examples## Fit classifier (splitting training into 70\% training data, 30\% validation data)
SC <- superClass(rlogo, trainData = train, responseCol = "class",
model = "rf", tuneLength = 1, trainPartition = 0.7)
-#> 15:22:30 | Begin sampling training data
-#> 15:22:30 | Starting to fit model
-#> 15:22:31 | Starting spatial predict
-#> 15:22:31 | Begin validation
+#> 15:32:05 | Begin sampling training data
+#> 15:32:05 | Starting to fit model
+#> 15:32:05 | Starting spatial predict
+#> 15:32:05 | Begin validation
#> ******************** Model summary ********************
#> Random Forest
#>
diff --git a/reference/tasseledCap.html b/reference/tasseledCap.html
index b82c411..54e16ad 100644
--- a/reference/tasseledCap.html
+++ b/reference/tasseledCap.html
@@ -28,7 +28,7 @@
diff --git a/reference/topCor.html b/reference/topCor.html
index b87241d..ce73e13 100644
--- a/reference/topCor.html
+++ b/reference/topCor.html
@@ -26,7 +26,7 @@
@@ -114,17 +114,17 @@ Examples
## Minnaert correction, solar angles from metaData
lsat_minnaert <- topCor(lsat, dem = srtm, metaData = metaData, method = "minnaert")
-#> 15:22:32 | Calculate slope and aspect
-#> 15:22:32 | Calculate illumination map
-#> 15:22:32 | Correct imagery
-#> 15:22:32 | Estimate coefficients
+#> 15:32:06 | Calculate slope and aspect
+#> 15:32:06 | Calculate illumination map
+#> 15:32:06 | Correct imagery
+#> 15:32:06 | Estimate coefficients
## C correction, solar angles provided manually
lsat_C <- topCor(lsat, dem = srtm, solarAngles = c(1.081533, 0.7023922), method = "C")
-#> 15:22:32 | Calculate slope and aspect
-#> 15:22:32 | Calculate illumination map
-#> 15:22:32 | Correct imagery
-#> 15:22:33 | Estimate coefficients
+#> 15:32:07 | Calculate slope and aspect
+#> 15:32:07 | Calculate illumination map
+#> 15:32:07 | Correct imagery
+#> 15:32:07 | Estimate coefficients
diff --git a/reference/unsuperClass.html b/reference/unsuperClass.html
index a78da3d..cc667ff 100644
--- a/reference/unsuperClass.html
+++ b/reference/unsuperClass.html
@@ -26,7 +26,7 @@
diff --git a/reference/validateMap.html b/reference/validateMap.html
index 8a0bc9d..270fcdd 100644
--- a/reference/validateMap.html
+++ b/reference/validateMap.html
@@ -26,7 +26,7 @@
@@ -94,9 +94,9 @@ Examples
## Classify (deliberately poorly)
sc <- superClass(lsat, trainData = train, responseCol = "class", nSamples = 50, model = "mlc")
-#> 15:22:33 | Begin sampling training data
-#> 15:22:33 | Starting to fit model
-#> 15:22:33 | Starting spatial predict
+#> 15:32:07 | Begin sampling training data
+#> 15:32:07 | Starting to fit model
+#> 15:32:07 | Starting spatial predict
#> ******************** Model summary ********************
#> Maximum Likelihood Classification
#>
diff --git a/reference/writeSLI.html b/reference/writeSLI.html
index 97a8635..316362f 100644
--- a/reference/writeSLI.html
+++ b/reference/writeSLI.html
@@ -26,7 +26,7 @@
diff --git a/search.json b/search.json
index 01b7aed..2d9e2ee 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://bleutner.github.io/RStoolbox/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Benjamin Leutner. Author. Ned Horning. Author. Jakob Schwalb-Willmann. Author. Robert J. Hijmans. Contributor. Konstantin Mueller. Author, maintainer.","code":""},{"path":"https://bleutner.github.io/RStoolbox/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Leutner B, Horning N, Schwalb-Willmann J, Mueller K (2024). RStoolbox: Remote Sensing Data Analysis. R package version 1.0.1, https://github.com/bleutner/RStoolbox, https://bleutner.github.io/RStoolbox/.","code":"@Manual{, title = {RStoolbox: Remote Sensing Data Analysis}, author = {Benjamin Leutner and Ned Horning and Jakob Schwalb-Willmann and Konstantin Mueller}, year = {2024}, note = {R package version 1.0.1, https://github.com/bleutner/RStoolbox}, url = {https://bleutner.github.io/RStoolbox/}, }"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"rstoolbox-","dir":"","previous_headings":"","what":"Remote Sensing Data Analysis","title":"Remote Sensing Data Analysis","text":"RStoolbox R package providing wide range tools every-day remote sensing processing needs. available tool-set covers many aspects data import, pre-processing, data analysis, image classification graphical display. RStoolbox builds upon terra package, makes suitable processing large data-sets even smaller workstations. Find RStoolbox webpage.","code":""},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Remote Sensing Data Analysis","text":"package available CRAN can installed usual via install latest version GitHub need r-base-dev (Linux) Rtools (Windows) installed. run following lines:","code":"install.packages(\"RStoolbox\") library(devtools) install_github(\"bleutner/RStoolbox\")"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"get-started","dir":"","previous_headings":"","what":"Get started","title":"Remote Sensing Data Analysis","text":"RStoolbox implements variety remote sensing methods workflows. examples get started. examples can found documentation respective functions.","code":""},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-1-classifications","dir":"","previous_headings":"Get started","what":"Example 1: Classifications","title":"Remote Sensing Data Analysis","text":"example shows unsupervised classification workflow based kmeans clustering: training data available, e.g. labeled polygons, RStoolbox can used conduct supervised classification. workflow employs randomForest train classification model: Created 2024-04-19 reprex v2.1.0","code":"library(RStoolbox) # unsupervised classification with 3 classes uc <- unsuperClass(lsat, nClasses = 3) # plot result using ggplot ggR(uc$map, geom_raster = T, forceCat = T) + scale_fill_manual(values = c(\"darkgreen\", \"blue\", \"sandybrown\")) 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\") + geom_sf(data = train, aes(fill = class)) + scale_fill_manual(values = c(\"yellow\", \"sandybrown\", \"darkgreen\", \"blue\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # 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, class_supervised = levels(train$class)) ggR(r, geom_raster = T, forceCat = T) + scale_fill_manual(values = c(\"yellow\", \"sandybrown\", \"darkgreen\", \"blue\"))"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-2-spectral-unmixing","dir":"","previous_headings":"Get started","what":"Example 2: Spectral Unmixing","title":"Remote Sensing Data Analysis","text":"RStoolbox offers spectral unmixing implementing Multiple Endmember Spectral Mixture Analysis (MESMA) approach estimating fractions spectral classes, spectra surfaces materials, sub-pixel scale. following workflow shows simple Spectral Mixture Analysis (SMA) single endmembers per class, extracted lsat example image cell id: Instead, one can define multiple endmembers per class conduct Multiple Endmember Spectral Mixture Analysis (MESMA):","code":"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) 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) # 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)"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-3-cloud-masking","dir":"","previous_headings":"Get started","what":"Example 3: Cloud Masking","title":"Remote Sensing Data Analysis","text":"RStoolbox comes suite pre-processing functions, including cloudMask identify clouds optical satellite imagery:","code":"library(ggplot2) # lsat example scene, with two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") # calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) # 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(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-4-radiometric-and-atmospheric-correction","dir":"","previous_headings":"Get started","what":"Example 4: Radiometric and atmospheric correction","title":"Remote Sensing Data Analysis","text":"radCor, users can compute radiometric simple atmospheric corrections (based dark object substraction): Created 2024-04-19 reprex v2.1.0","code":"library(terra) # import Landsat meta data mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) # convert DN to top of atmosphere reflectance and brightness temperature lsat_ref <- radCor(lsat_t, metaData = metaData, method = \"apref\") # correct DN to at-surface-reflecatance with DOS (Chavez decay model) lsat_sref <- radCor(lsat_t, metaData = metaData) # correct DN to at-surface-reflecatance with simple DOS and automatic haze estimation hazeDN <- estimateHaze(lsat_t, hazeBands = 1:4, darkProp = 0.01, plot = FALSE) lsat_sref <- 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\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":null,"dir":"Reference","previous_headings":"","what":"ImageMetaData Class — ImageMetaData","title":"ImageMetaData Class — ImageMetaData","text":"ImageMetaData Class","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ImageMetaData Class — ImageMetaData","text":"","code":"ImageMetaData( file = NA, format = NA, sat = NA, sen = NA, scene = NA, colNum = NA, colTier = NA, proj = NA, date = NA, pdate = NA, path = NA, row = NA, az = NA, selv = NA, esd = NA, files = NA, bands = NA, quant = NA, cat = NA, na = NA, vsat = NA, scal = NA, dtyp = NA, calrad = NA, calref = NA, calbt = NA, radRes = NA, spatRes = NA )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ImageMetaData Class — ImageMetaData","text":"file Character. Metadata file format Character. Metadata format, e.g. xml, mtl sat Character. Satellite platform sen Character. Sensor scene Character. Scene_ID colNum Character Collection number colTier Character Collection tier proj CRS. Projection. date POSIXct. Aquisition date. pdate POSIXct. Processing date. path Integer. Path. row Integer. Row. az Numeric. Sun azimuth selv Numeric. Sun elevation esd Numeric. Earth-sun distance files Character vector. Files containing data, e.g. tiff files bands Character vector. Band names quant Character vector. Quantity, one c(\"dn\", \"tra\", \"tre\", \"sre\", \"bt\", \"idx\", \"angle\") cat Character vector. Category, e.g. c(\"image\", \"pan\", \"index\", \"qa\", \"aux\") na Numeric vector. -data value per band vsat Numeric vector. Saturation value per band scal Numeric vector. Scale factor per band. e.g. data scaled 1000*reflectance integer conversion. dtyp Character vector. Data type per band. calrad data.frame. Calibration coefficients dn->radiance conversion. Must columns 'gain' 'offset'. Rows named according bands. calref data.frame. Calibration coefficients dn->reflectance conversion. Must columns 'gain' 'offset'. Rows named according bands. calbt data.frame. Calibration coefficients dn->brightness temperature conversion. Must columns 'K1' 'K2'. Rows named according bands. radRes Numeric vector. Radiometric resolution per band. spatRes Numeric vector. Spatial resolution per band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"ImageMetaData Class — ImageMetaData","text":"Returns structured, fully customizable meta-data table file","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":null,"dir":"Reference","previous_headings":"","what":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"RStoolbox package provides set functions simplify performing standard remote sensing tasks R.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-import-and-export","dir":"Reference","previous_headings":"","what":"Data Import and Export","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"readMeta: import Landsat metadata MTL XML files stackMeta, getMeta: load Landsat bands based metadata readSLI & writeSLI: read write ENVI spectral libraries saveRSTBX & readRSTBX: save re-import RStoolbox classification objects (model map) readEE: import tidy EarthExplorer search results","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-pre-processing","dir":"Reference","previous_headings":"","what":"Data Pre-Processing","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"radCor: radiometric conversions corrections. Primarily, yet exclusively, intended Landsat data processing. DN radiance reflectance conversion well DOS approaches topCor: topographic illumination correction cloudMask & cloudShadowMask: mask clouds cloud shadows Landsat imagery comes thermal band classifyQA: extract layers Landsat 8 QA bands, e.g. cloud confidence encodeQA & decodeQA: encode/decode Landsat 16-bit QA bands. rescaleImage: rescale image match min/max another image specified min/max range normImage: normalize imagery centering scaling oneHotEncode: one-hot encode raster vector histMatch: matches histograms two scenes pifMatch: matches one scene another based linear regression Pseudo-Invariant Features (PIF) coregisterImages: co-register images based mutual information panSharpen: sharpen coarse resolution image high resolution image (typically panchromatic) estimateHaze: estimate image haze Dark Object Subtraction (DOS)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-analysis","dir":"Reference","previous_headings":"","what":"Data Analysis","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"spectralIndices: calculate set predefined multispectral indices like NDVI tasseledCap: tasseled cap transformation sam: spectral angle mapper rasterPCA: principal components transform raster data rasterCVA: change vector analysis rasterEntropy: calculates shannon entropy unsuperClass: unsupervised classification superClass, validateMap, getValidation: supervised classification validation fCover: fractional cover coarse resolution imagery based high resolution classification mesma: spectral unmixing using Multiple Endmember Spectral Mixture Analysis (MESMA)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-display","dir":"Reference","previous_headings":"","what":"Data Display","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"ggR: single raster layer plotting ggplot2 ggRGB: efficient plotting remote sensing imagery RGB ggplot2","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Classify Landsat QA bands — classifyQA","title":"Classify Landsat QA bands — classifyQA","text":"extracts five classes QA band: background, cloud, cirrus, snow water.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Classify Landsat QA bands — classifyQA","text":"","code":"classifyQA( img, type = c(\"background\", \"cloud\", \"cirrus\", \"snow\", \"water\"), confLayers = FALSE, sensor = \"OLI\", legacy = \"collection1\", ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Classify Landsat QA bands — classifyQA","text":"img SpatRaster. Landsat 8 OLI QA band. type Character. Classes returned. One c(\"background\", \"cloud\", \"cirrus\",\"snow\", \"water\"). confLayers Logical. Return one layer per class classified confidence levels, .e. cloud:low, cloud:med, cloud:high. sensor Sensor encode. Options: c(\"OLI\", \"TIRS\", \"ETM+\", \"TM\", \"MSS\"). legacy Encoding systematic Options: c(\"collection1\", \"pre_collection\"). Default \"collection1\" Landsat Collection 1 8-bit quality designations. Use \"pre_collection\" imagery downloaded Collection 1 quality designations introduced ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Classify Landsat QA bands — classifyQA","text":"Returns SpatRaster maximal five classes: Values outside classes returned NA. confLayers = TRUE RasterStack one layer per condition (except 'background') returned, whereby layer contains confidence level condition.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Classify Landsat QA bands — classifyQA","text":"default class queried *high* confidence. See encodeQA details. return different confidence levels per condition use confLayers=TRUE. approach corresponds way LandsatLook Quality Images produced USGS.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Classify Landsat QA bands — classifyQA","text":"","code":"library(terra) #> terra 1.7.83 qa <- rast(ncol = 100, nrow=100, val = sample(1:2^14, 10000)) ## QA classes qacs <- classifyQA(img = qa) ## Confidence levels qacs_conf <- classifyQA(img = qa, confLayers = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":null,"dir":"Reference","previous_headings":"","what":"Simple Cloud Detection — cloudMask","title":"Simple Cloud Detection — cloudMask","text":"Developed use Landsat data cloudMask relies distinctive difference blue (short-wave band) thermal band semi-automated creation cloud mask. Since relies thermal information work well sensors without thermal bands.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simple Cloud Detection — cloudMask","text":"","code":"cloudMask( x, threshold = 0.2, blue = \"B1_sre\", tir = \"B6_sre\", buffer = NULL, plot = FALSE, verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simple Cloud Detection — cloudMask","text":"x SpatRaster reflectance brightness temperature mask previous run cloudMask returnDiffLayer=TRUE. threshold Numeric. cloud detection threshold. provided guessed. Everything ** threshold considered cloud pixel (unless removed filtering afterwards). blue Character integer. Bandname number blue band tir Character integer. Bandname number thermal band buffer Integer. Number pixels use buffer added identified cloud centers. plot Logical. Plots cloud mask sub-steps (sanitizing etc.) Helpful find proper parametrization. verbose Logical. Print messages suppress.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simple Cloud Detection — cloudMask","text":"Returns SpatRaster two layers: CMASK contains binary cloud mask (1 = cloud, NA = -cloud) NDTCI contains cloud index.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Simple Cloud Detection — cloudMask","text":"Typically clouds cold thermal region high reflectance short wavelengths (blue). calculating normalized difference index two bands thresholding rough cloud mask can obtained. calculating spectral cloud index (call Normalized Difference Thermal Cloud Index (NDTCI)) thermal band matched value range blue band. Therefore, matter whether provide DN, radiance brightness temperature. approach cloud masking simplistic. aims rough removal potentially clouded areas. Nevertheless, able provide satisfactory results. sophisticated approaches, including cloud cast shadow detection can found elsewhere, e.g. fmask. can make sense find suitable threshold cropped version scene. Also make sure make use returnDiffLayer argument save one processing step. Buffering seen final polishing, .e. long pure cloud centers detected properly, might want turn . since takes time calculate. mask detects obvious cloud pixels properly re-enable buffering fine tuning desired. Finally, suitable threshold established re-run cloudMask whole scene threshold go get coffee.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simple Cloud Detection — cloudMask","text":"","code":"library(ggplot2) ## Import Landsat example subset ## We have two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") ## Calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) ## Define threshold (re-use the previously calculated index) ## Everything above the threshold is masked ## In addition we apply a region-growing around the core cloud pixels cldmsk_final <- cloudMask(cldmsk, threshold = 0.1, buffer = 5) ## Plot cloudmask ggRGB(lsat, stretch = \"lin\") + ggR(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`). #' ## Estimate cloud shadow displacement ## Interactively (click on cloud pixels and the corresponding shadow pixels) if (FALSE) shadow <- cloudShadowMask(lsat, cldmsk_final, nc = 2) # \\dontrun{} ## Non-interactively. Pre-defined shadow displacement estimate (shiftEstimate) shadow <- cloudShadowMask(lsat, cldmsk_final, shiftEstimate = c(-16,-6)) ## Plot csmask <- terra::merge(cldmsk_final[[1]], shadow) ggRGB(lsat, stretch = \"lin\") + ggR(csmask, ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"blue\", \"yellow\"), labels = c(\"shadow\", \"cloud\"), na.value = NA) #> Warning: Removed 88534 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":null,"dir":"Reference","previous_headings":"","what":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"Intended interactive use, cloudShadowMask ask user select corresponding cloud/cloudShadow pixels used estimate coordinates linear cloudmask shift.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"","code":"cloudShadowMask( img, cm, nc = 5, shiftEstimate = NULL, preciseShift = NULL, quantile = 0.2, returnShift = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"img SpatRaster containing scene cm SpatRaster. Cloud mask (typically result cloudMask) nc Integer. Number control points. points (default) fine final shift estimated coregisterImages. shiftEstimate NULL numeric vector length two (x,y). Estimated displacement shadows map units. NULL, user asked select control points interactively. preciseShift NULL numeric vector length two (x,y). Use cloud/cloud-shadow displacement already known, e.g. previous run cloudShadowMask. quantile Numeric (0 1). Quantile threshold used image co-registration. default 20% quantile total intensity (sum) image used potential shadow mask. returnShift Logical. Return numeric vector containing shift parameters. Useful estimate parameters subset image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"Returns RasterLayer cloud shadow mask (0 = shadow, NA = -shadow).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"simplistic approach cloud shadow masking (simple shift cloud mask). image based accuracy suffer clouds different altitudes. However, just cloudMask quick easy use tool Landsat data just working scenes fMask CDR data hand. Although test scenes perform surprisingly well.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"","code":"library(ggplot2) ## Import Landsat example subset ## We have two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") ## Calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) ## Define threshold (re-use the previously calculated index) ## Everything above the threshold is masked ## In addition we apply a region-growing around the core cloud pixels cldmsk_final <- cloudMask(cldmsk, threshold = 0.1, buffer = 5) ## Plot cloudmask ggRGB(lsat, stretch = \"lin\") + ggR(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`). #' ## Estimate cloud shadow displacement ## Interactively (click on cloud pixels and the corresponding shadow pixels) if (FALSE) shadow <- cloudShadowMask(lsat, cldmsk_final, nc = 2) # \\dontrun{} ## Non-interactively. Pre-defined shadow displacement estimate (shiftEstimate) shadow <- cloudShadowMask(lsat, cldmsk_final, shiftEstimate = c(-16,-6)) ## Plot csmask <- terra::merge(cldmsk_final[[1]], shadow) ggRGB(lsat, stretch = \"lin\") + ggR(csmask, ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"blue\", \"yellow\"), labels = c(\"shadow\", \"cloud\"), na.value = NA) #> Warning: Removed 88534 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":null,"dir":"Reference","previous_headings":"","what":"Image to Image Co-Registration based on Mutual Information — coregisterImages","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"Shifts image match reference image. Matching based maximum mutual information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"","code":"coregisterImages( img, ref, shift = 3, shiftInc = 1, nSamples = 100, reportStats = FALSE, verbose, nBins = 100, master = deprecated(), slave = deprecated(), ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"img SpatRaster. Image shift match reference image. img ref must equal numbers bands. ref SpatRaster. Reference image. img ref must equal numbers bands. shift Numeric matrix. numeric, shift maximal absolute radius (pixels img resolution) img shifted (seq(-shift, shift, =shiftInc)). shift matrix must two columns (x shift y shift), shift values tested. shiftInc Numeric. Shift increment (pixels, restricted integer). Ignored shift matrix. nSamples Integer. Number samples calculate mutual information. reportStats Logical. FALSE return shifted images. Otherwise return shifted image list containing stats mutual information per shift joint histograms. verbose Logical. Print status messages. Overrides global RStoolbox.verbose option. nBins Integer. Number bins calculate joint histogram. master DEPRECATED! Argument renamed. Please use ref now . slave DEPRECATED! Argument renamed. Please use img now . ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"reportStats=FALSE returns SpatRaster (x-y shifted image). reportStats=TRUE returns list containing data.frame mutual information per shift ($MI), shift maximum MI ($bestShift), joint histograms per shift list ($jointHist) shifted image ($coregImg).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"Currently simple linear x - y shift considered tested. higher order shifts (e.g. rotation, non-linear transformation) performed. means imagery already properly geometrically corrected. Mutual information similarity metric originating information theory. Roughly speaking, higher mutual information two data-sets, higher shared information content, .e. similarity. two images exactly co-registered mutual information maximal. trying different image shifts, aim find best overlap maximises mutual information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"","code":"library(terra) library(ggplot2) library(reshape2) reference <- rlogo ## Shift reference 2 pixels to the right and 3 up missreg <- shift(reference, 2, 3) ## Compare shift p <- ggR(reference, sat = 1, alpha = .5) p + ggR(missreg, sat = 1, hue = .5, alpha = 0.5, ggLayer=TRUE) ## Coregister images (and report statistics) coreg <- coregisterImages(missreg, ref = reference, nSamples = 500, reportStats = TRUE) ## Plot mutual information per shift ggplot(coreg$MI) + geom_raster(aes(x,y,fill=mi)) ## Plot joint histograms per shift (x/y shift in facet labels) # \\donttest{ df <- melt(coreg$jointHist) df$L1 <- factor(df$L1, levels = names(coreg$jointHist)) df[df$value == 0, \"value\"] <- NA ## don't display p = 0 ggplot(df) + geom_raster(aes(x = Var2, y = Var1,fill=value)) + facet_wrap(~L1) + scale_fill_gradientn(name = \"p\", colours = heat.colors(10), na.value = NA) #> Warning: Removed 443028 rows containing missing values or values outside the scale range #> (`geom_raster()`). # } ## Compare correction ggR(reference, sat = 1, alpha = .5) + ggR(coreg$coregImg, sat = 1, hue = .5, alpha = 0.5, ggLayer=TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Decode QA flags to bit-words — decodeQA","title":"Decode QA flags to bit-words — decodeQA","text":"Intended use Landsat 16-bit QA bands. Decodes pixel quality flags integer bit-words.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decode QA flags to bit-words — decodeQA","text":"","code":"decodeQA(x)"},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decode QA flags to bit-words — decodeQA","text":"x Integer (16bit)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decode QA flags to bit-words — decodeQA","text":"Returns decoded QA values integer","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decode QA flags to bit-words — decodeQA","text":"","code":"decodeQA(53248) #> [1] \"1101000000000000\""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Encode QA Conditions to Integers — encodeQA","title":"Encode QA Conditions to Integers — encodeQA","text":"Intended use Landsat 16-bit QA bands. Converts pixel quality flags human readable integer, can used subset QA image. Please aware default settings differ different parameters. Depending , sensor legacy selected, quality parameters used, since sequences available bitwise quality designations differ per sensor collection.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Encode QA Conditions to Integers — encodeQA","text":"","code":"encodeQA( fill = \"no\", terrainOcclusion = \"no\", radSaturation = \"na\", cloudMask = \"all\", cloud = \"all\", cloudShadow = \"all\", snow = \"all\", cirrus = \"all\", droppedPixel = \"no\", water = \"all\", droppedFrame = \"no\", sensor = \"OLI\", legacy = \"collection1\" )"},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Encode QA Conditions to Integers — encodeQA","text":"fill Designated fill. Options: c(\"yes\", \"\", \"\"). terrainOcclusion Terrain induced occlusion. Options: c(\"yes\", \"\", \"\"). radSaturation Number bands contain radiometric saturation. Options: c(\"na\", \"low\", \"med\", \"high\", \"\") bands, 1-2 bands, 3-4 bands, 5 bands contain saturation. cloudMask Cloud mask. Options: c(\"yes\", \"\", \"\"). cloud Cloud confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). cloudShadow Cloud shadow confidence. Options: c(\"yes\", \"\", \"\"). snow Snow / ice confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). cirrus Cirrus confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). droppedPixel Dropped pixel. Options: c(\"yes\", \"\", \"\"). water Water confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). droppedFrame Dropped frame. Options: c(\"yes\", \"\", \"\"). sensor Sensor encode. Options: c(\"OLI\", \"TIRS\", \"ETM+\", \"TM\", \"MSS\"). legacy Encoding systematic Options: c(\"collection1\", \"pre_collection\"). Default \"collection1\" Landsat Collection 1 8-bit quality designations. Use \"pre_collection\" imagery downloaded Collection 1 quality designations introduced","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Encode QA Conditions to Integers — encodeQA","text":"Returns Integer value QA values","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Encode QA Conditions to Integers — encodeQA","text":"currently populated bits available arguments.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Encode QA Conditions to Integers — encodeQA","text":"https://www.usgs.gov/landsat-missions/landsat-collection-1-level-1-quality-assessment-band Collection 1 quality designations (legacy = \"collection1\")","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Encode QA Conditions to Integers — encodeQA","text":"","code":"encodeQA(snow = \"low\", cirrus = c(\"med\", \"high\"), cloud = \"high\") #> [1] 23136 23264 23392 23520 23152 23280 23408 23536"},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"estimates digital number (DN) pixel value *dark* objects visible wavelength range.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"","code":"estimateHaze( x, hazeBands, darkProp = 0.01, maxSlope = TRUE, plot = FALSE, returnTables = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"x SpatRaster previous result estimateHaze returnTables = TRUE estimate haze hazeBands Integer Character. Band number bandname estimate atmospheric haze (optional x contains one layer) darkProp Numeric. Proportion pixels estimated dark. maxSlope Logical. Use darkProp upper boundary search DN maximum slope histogram value. plot Logical. Option display histograms haze values returnTables Logical. Option return frequency table per layer. takes effect x SpatRaster. x result estimateHaze tables always returned.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"returnTables FALSE (default). vector length(hazeBands) containing estimated haze DNs returned. returnTables TRUE list two components returned. list element 'SHV' contains haze values, 'table' contains another list sampled frequency tables. latter can re-used try different darkProp thresholds without sample raster .","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"assumed radiation originating *dark* pixels due atmospheric haze reflectance surface (surface dark, .e. reflectance close zero). Hence, haze values estimates path radiance, can subtracted dark object subtraction (DOS) procedure (see radCor) Atmospheric haze affects almost exclusively visible wavelength range. Therefore, typically, want estimate haze blue, green red bands, occasionally also nir band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"","code":"## Estimate haze for blue, green and red band haze <- estimateHaze(lsat, hazeBands = 1:3, plot = FALSE) haze #> B1_dn B2_dn B3_dn #> 55 19 12 ## Find threshold interactively #### Return the frequency tables for re-use #### avoids having to sample the Raster again and again haze <- estimateHaze(lsat, hazeBands = 1:3, returnTables = TRUE) ## Use frequency table instead of lsat and fiddle with haze <- estimateHaze(haze, hazeBands = 1:3, darkProp = .1, plot = FALSE) haze$SHV #> B1_dn B2_dn B3_dn #> 57 20 12"},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":null,"dir":"Reference","previous_headings":"","what":"Fractional Cover Analysis — fCover","title":"Fractional Cover Analysis — fCover","text":"fCover takes classified high resolution image, e.g. vegetation non-vegetation based Landsat calculates cover fractions pixels coarser resolution, e.g. MODIS.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fractional Cover Analysis — fCover","text":"","code":"fCover( classImage, predImage, nSamples = 1000, classes = 1, maxNA = 0, clamp = TRUE, model = \"rf\", tuneLength = 3, trControl = trainControl(method = \"cv\"), method = deprecated(), filename = NULL, overwrite = FALSE, verbose, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fractional Cover Analysis — fCover","text":"classImage high resolution SpatRaster containing landcover classification, e.g. obtained superClass. predImage coarse resolution SpatRaster fractional cover estimated. nSamples Integer. Number pixels sample predImage train regression model classes Integer. Classes fractional cover estimated (one ). maxNA Numeric. Maximal proportion NAs allowed training pixels. clamp Logical. Enforce results stay within [0,1] interval. Values <0 reset 0 values >1 1. model Character. model fit image regression. See train options. Defaults randomForest ('rf') tuneLength Integer. Number levels tuning parameters generated train. See Details train. trControl trainControl object, specifying resampling, validation etc. method DEPREACTED! favor trControl=trainControl(method=\"cv\") Resampling method parameter tuning. Defaults 10 fold cross-validation. See trainControl options. filename Character. Filename output raster file (optional). overwrite Logical. TRUE, filename overwritten. verbose Logical. Print progress information. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fractional Cover Analysis — fCover","text":"Returns list two elements: models contains fitted models evaluated tenfold cross-validation (caret train objects); fCover contains SpatRaster fractional cover layer requested class.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fractional Cover Analysis — fCover","text":"fCover gets pixel values high resolution classified image correspond randomly selected moderate resolution pixels calculates percent classified image pixels represent cover type interest. words, high resolution image pixel size 1m moderate resolution image pixel size 30m sampling process take block 900 1m resolution pixels correspond single 30m pixel calculate percentage 1m pixels forest. example, 600 forest pixels 300 non-forest pixels value given output pixel 0.67 since 67 fCover relies train() function caret package provides access huge number classifiers. Please see available options train. default classifier (randomForest) chose shown provide good results image regression hence recomended start one. choose different classifier, make sure can run regression mode. Many models require tuning certain parameters. , handled train caret package. tuneLength argument can specify many different values tuning parameter tested. Random Forest algorithm example can tuned varying mtry parameter. Hence, specifying tuneLength = 10, ten different levels mtry tested cross-validation scheme best-performing value chosen final model. total -data values block high resolution pixels greater maxNA included training data set since much missing data provide reliable cover percentage. -data proporton less maxNA -data pixels removed total number pixels calculating percent cover.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fractional Cover Analysis — fCover","text":"","code":"# \\donttest{ library(terra) library(caret) #> Loading required package: lattice ## Create fake input images agg.level <- 9 modis <- terra::aggregate(rlogo, agg.level) ## Perform an exemplary classification lc <- unsuperClass(rlogo, nClass=2) ## Calculate the true cover, which is of course only possible in this example, ## because the fake corse resolution imagery is exactly res(rlogo)*9 trueCover <- terra::aggregate(lc$map, agg.level, fun = function(x, ...){sum(x == 1, ...)/sum(!is.na(x))}) ## Run with randomForest and support vector machine (radial basis kernel) ## Of course the SVM is handicapped in this example, ## due to poor tuning (tuneLength) par(mfrow=c(2,3)) for(model in c(\"rf\", \"svmRadial\")){ fc <- fCover( classImage = lc$map , predImage = modis, classes=1, trControl = trainControl(method = \"cv\", number = 3), model=model, nSample = 50, tuneLength=2 ) ## How close is it to the truth? compare.rf <- trueCover - fc$map plot(fc$map, main = paste(\"Fractional Cover: Class 1\\nModel:\", model)) plot(compare.rf, main = \"Diffence\\n true vs. predicted\") plot(trueCover[],fc$map[], xlim = c(0,1), ylim =c(0,1), xlab = \"True Cover\", ylab = \"Predicted Cover\" ) abline(coef=c(0,1)) rmse <- sqrt(global(compare.rf^2, \"sum\", na.rm = TRUE))/ncell(compare.rf) r2 <- cor(trueCover[], fc$map[], \"complete.obs\") text(0.9,0.1, adj=1, labels = paste(c(\"RMSE:\",\"\\nR2:\"), round(unlist(c(rmse, r2)),3), collapse=\"\")) } ## Reset par par(mfrow=c(1,1)) # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":null,"dir":"Reference","previous_headings":"","what":"Fortify method for classes from the terra package. — fortifySpatRaster","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"Fortify method classes terra package.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"","code":"fortifySpatRaster(x, maxpixels = 50000)"},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"x SpatRaster object convert dataframe. maxpixels Integer. Maximum number pixels sample","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"Returns data.frame coordinates (x,y) corresponding raster values.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"","code":"r_df <- fortifySpatRaster(rlogo) head(r_df) #> x y red green blue #> 1 0.5 76.5 255 255 255 #> 2 1.5 76.5 255 255 255 #> 3 2.5 76.5 255 255 255 #> 4 3.5 76.5 255 255 255 #> 5 4.5 76.5 255 255 255 #> 6 5.5 76.5 255 255 255"},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract bandwise information from ImageMetaData — getMeta","title":"Extract bandwise information from ImageMetaData — getMeta","text":"accessor function quickly access information stored ImageMetaData, e.g. scale factor per band. Intended use imagery imported using stackMeta. return parameters using actual band order img.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract bandwise information from ImageMetaData — getMeta","text":"","code":"getMeta(img, metaData, what)"},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract bandwise information from ImageMetaData — getMeta","text":"img SpatRaster character vector band names. metaData ImageMetaData path meta data file. Character. Parameter extract. Either data descriptors, conversion parameters (see Details options)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract bandwise information from ImageMetaData — getMeta","text":"one c('CALRAD', 'CALBT', 'CALREF') data.frame returned bands rows (order corresponding img band order). Otherwise named numeric vector corresponding parameter returned (layernames names).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract bandwise information from ImageMetaData — getMeta","text":"Possible metadata parameters (argument): Data descriptors Conversion parameters","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract bandwise information from ImageMetaData — getMeta","text":"","code":"## Import example data mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") meta <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) ## Get integer scale factors getMeta(lsat_t, metaData = meta, what = \"SCALE_FACTOR\") #> B1_dn B2_dn B3_dn B4_dn B5_dn B6_dn B7_dn #> 1 1 1 1 1 1 1 ## Conversion factors for brightness temperature getMeta(\"B6_dn\", metaData = meta, what = \"CALBT\") #> K1 K2 #> B6_dn 607.76 1260.56 ## Conversion factors to top-of-atmosphere radiance ## Band order not corresponding to metaData order getMeta(lsat_t[[5:1]], metaData = meta, what = \"CALRAD\") #> offset gain #> B5_dn -0.49035 0.120 #> B4_dn -2.38602 0.876 #> B3_dn -2.21398 1.044 #> B2_dn -4.16220 1.322 #> B1_dn -2.19134 0.671 ## Get integer scale factors getMeta(lsat_t, metaData = meta, what = \"SCALE_FACTOR\") #> B1_dn B2_dn B3_dn B4_dn B5_dn B6_dn B7_dn #> 1 1 1 1 1 1 1 ## Get file basenames getMeta(lsat_t, metaData = meta, what = \"FILES\") #> B1_dn B2_dn #> \"LT52240631988227CUB02_B1.TIF\" \"LT52240631988227CUB02_B2.TIF\" #> B3_dn B4_dn #> \"LT52240631988227CUB02_B3.TIF\" \"LT52240631988227CUB02_B4.TIF\" #> B5_dn B6_dn #> \"LT52240631988227CUB02_B5.TIF\" \"LT52240631988227CUB02_B6.TIF\" #> B7_dn #> \"LT52240631988227CUB02_B7.TIF\""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract validation results from superClass objects — getValidation","title":"Extract validation results from superClass objects — getValidation","text":"Extract validation results superClass objects","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract validation results from superClass objects — getValidation","text":"","code":"getValidation(x, from = \"testset\", metrics = \"overall\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract validation results from superClass objects — getValidation","text":"x superClass object caret::confusionMatrix Character. 'testset' extracts results independent validation testset. 'cv' extracts cross-validation results. metrics Character. relevant classification mode (ignored regression models). Select 'overall' overall accuracy metrics, 'classwise' classwise metrics, 'confmat' confusion matrix 'caret' return whole caret::confusionMatrix object.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract validation results from superClass objects — getValidation","text":"Returns data.frame validation results. metrics = 'confmat' 'caret' return table full caret::confusionMatrix object, respectively.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract validation results from superClass objects — getValidation","text":"","code":"library(pls) #> #> Attaching package: ‘pls’ #> The following object is masked from ‘package:caret’: #> #> R2 #> The following object is masked from ‘package:stats’: #> #> loadings ## Fit classifier (splitting training into 70\\% training data, 30\\% validation data) train <- readRDS(system.file(\"external/trainingPoints_rlogo.rds\", package=\"RStoolbox\")) SC <- superClass(rlogo, trainData = train, responseCol = \"class\", model=\"pls\", trainPartition = 0.7) ## Independent testset-validation getValidation(SC) #> model validation Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull #> 1 pls testset 0.8888889 0.8333333 0.5175035 0.9971909 0.3333333 #> AccuracyPValue McnemarPValue #> 1 0.0009653 NaN getValidation(SC, metrics = \"classwise\") #> model validation class Sensitivity Specificity Pos.Pred.Value Neg.Pred.Value #> 1 pls testset A 1.0000000 0.8333333 0.75 1.0000000 #> 2 pls testset B 0.6666667 1.0000000 1.00 0.8571429 #> 3 pls testset C 1.0000000 1.0000000 1.00 1.0000000 #> Precision Recall F1 Prevalence Detection.Rate Detection.Prevalence #> 1 0.75 1.0000000 0.8571429 0.3333333 0.3333333 0.4444444 #> 2 1.00 0.6666667 0.8000000 0.3333333 0.2222222 0.2222222 #> 3 1.00 1.0000000 1.0000000 0.3333333 0.3333333 0.3333333 #> Balanced.Accuracy #> 1 0.9166667 #> 2 0.8333333 #> 3 1.0000000 ## Cross-validation based getValidation(SC, from = \"cv\") #> model validation Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull #> 1 pls cv 0.8571429 0.7857143 0.636576 0.969511 0.3333333 #> AccuracyPValue McnemarPValue #> 1 1.101588e-06 NaN"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot RasterLayers in ggplot with greyscale — ggR","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"Plot single layer imagery grey-scale. Can used SpatRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"","code":"ggR( img, layer = 1, maxpixels = 5e+05, alpha = 1, hue = 1, sat = 0, stretch = \"none\", quantiles = c(0.02, 0.98), ext = NULL, coord_equal = TRUE, ggLayer = FALSE, ggObj = TRUE, geom_raster = FALSE, forceCat = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"img SpatRaster layer Character numeric. Layername number. Can one layer, case layer plotted subplot. maxpixels Integer. Maximal number pixels sample. alpha Numeric. Transparency (0-1). hue Numeric. Hue value color calculation [0,1] (see hsv). Change need anything else greyscale. effective sat > 0. sat Numeric. Saturation value color calculation [0,1] (see hsv). Change need anything else greyscale. stretch Character. Either 'none', 'lin', 'hist', 'sqrt' 'log' stretch, linear, histogram, square-root logarithmic stretch. quantiles Numeric vector two elements. Min max quantiles stretch . Defaults 2% stretch, .e. c(0.02,0.98). ext Extent object crop image coord_equal Logical. Force addition coord_equal, .e. aspect ratio 1:1. Typically useful remote sensing data (depending projection), hence defaults TRUE. Note however, apply (ggLayer=FALSE). ggLayer Logical. Return ggplot layer must added existing ggplot. FALSE s stand-alone ggplot returned. ggObj Logical. Return stand-alone ggplot object (TRUE) just data.frame values colors geom_raster Logical. FALSE uses annotation_raster (good keep aestetic mappings free). TRUE uses geom_raster (aes(fill)). See Details. forceCat Logical. TRUE raster values forced categorical (converted factor needed).","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"img contains factor values annotation=TRUE, raster values automatically converted numeric order proceed brightness calculation. geom_raster argument switches default use annotation_raster geom_raster. difference two geom_raster performs meaningful mapping pixel values fill colour, annotation_raster simply adding picture plot. practice means whenever need legend raster use geom_raster = TRUE. also allows specify modify fill scale manually. advantage using annotation_raster (geom_raster = TRUE) can still use scale_fill* another variable. example add polygons map value fill colour. details theory behind aestetic mapping look ggplot2 manuals.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"","code":"library(ggplot2) library(terra) ## Simple grey scale annotation ggR(rlogo) ## With linear stretch contrast enhancement ggR(rlogo, stretch = \"lin\", quantiles = c(0.1,0.9)) ## ggplot with geom_raster instead of annotation_raster ## and default scale_fill* ggR(rlogo, geom_raster = TRUE) ## with different scale ggR(rlogo, geom_raster = TRUE) + scale_fill_gradientn(name = \"mojo\", colours = rainbow(10)) + ggtitle(\"**Funkadelic**\") ## Plot multiple layers # \\donttest{ ggR(lsat, 1:6, geom_raster=TRUE, stretch = \"lin\") + scale_fill_gradientn(colors=grey.colors(100), guide = \"none\") + theme(axis.text = element_text(size=5), axis.text.y = element_text(angle=90), axis.title=element_blank()) ## Don't plot, just return a data.frame df <- ggR(rlogo, ggObj = FALSE) head(df, n = 3) #> x y value layerName fill #> 1 0.5 76.5 255 red #FFFFFFFF #> 2 1.5 76.5 255 red #FFFFFFFF #> 3 2.5 76.5 255 red #FFFFFFFF ## Layermode (ggLayer=TRUE) data <- data.frame(x = c(0, 0:100,100), y = c(0,sin(seq(0,2*pi,pi/50))*10+20, 0)) ggplot(data, aes(x, y)) + ggR(rlogo, geom_raster= FALSE, ggLayer = TRUE) + geom_polygon(aes(x, y), fill = \"blue\", alpha = 0.4) + coord_equal(ylim=c(0,75)) ## Categorical data ## In this case you probably want to use geom_raster=TRUE ## in order to perform aestetic mapping (i.e. a meaningful legend) rc <- rlogo rc[] <- cut(rlogo[[1]][], seq(0,300, 50)) ggR(rc, geom_raster = TRUE) ## Legend cusomization etc. ... ggR(rc, geom_raster = TRUE) + scale_fill_continuous(labels=paste(\"Class\", 1:6)) # } ## Creating a nicely looking DEM with hillshade background terr <- terrain(srtm, c(\"slope\", \"aspect\")) hill <- shade(terr[[\"slope\"]], terr[[\"aspect\"]]) ggR(hill) ggR(hill) + ggR(srtm, geom_raster = TRUE, ggLayer = TRUE, alpha = 0.3) + scale_fill_gradientn(colours = terrain.colors(100), name = \"elevation\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":null,"dir":"Reference","previous_headings":"","what":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"Calculates RGB color composite raster plotting ggplot2. Optional values clipping stretching can used enhance imagery.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"","code":"ggRGB( img, r = 3, g = 2, b = 1, scale, maxpixels = 5e+05, stretch = \"none\", ext = NULL, limits = NULL, clipValues = \"limits\", quantiles = c(0.02, 0.98), ggObj = TRUE, ggLayer = FALSE, alpha = 1, coord_equal = TRUE, geom_raster = FALSE, nullValue = 0 )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"img SpatRaster r Integer character. Red layer x. Can set NULL, case red channel set zero. g Integer character. Green layer x. Can set NULL, case green channel set zero. b Integer character. Blue layer x. Can set NULL, case blue channel set zero. scale Numeric. Maximum possible pixel value (optional). Defaults 255 maximum value x larger 255 maxpixels Integer. Maximal number pixels used plotting. stretch Character. Either 'none', 'lin', 'hist', 'sqrt' 'log' stretch, linear, histogram, square-root logarithmic stretch. ext Extent SpatExtent object crop image limits Vector matrix. Can used reduce range values. Either vector two values bands (c(min, max)) 3x2 matrix min max values (columns) layer (rows). clipValues Matrix, numeric vector, string NA. Values reset range (limits) values . default ('limits') values reset limits. single value (e.g. NA) recycled lower/higher clippings, vector length two (c(min,max)) can used specify lower higher replace values, applied bands. two column matrix (typically three rows) can used fully control lower upper clipping values differently band. quantiles Numeric vector two elements. Min max quantiles stretch. Defaults 2% stretch, .e. c(0.02,0.98). ggObj Logical. TRUE ggplot2 object returned. FALSE data.frame coordinates color returned. ggLayer Logical. TRUE ggplot2 layer returned. useful want add existing ggplot2 object. Note TRUE & annotate = FALSE add scale_fill_identity() manually call ggplot(). alpha Numeric. Transparency (0-1). coord_equal Logical. Force addition coord_equal, .e. aspect ratio 1:1. Typically useful remote sensing data (depending projection), hence defaults TRUE. Note howver, apply (ggLayer=FALSE). geom_raster Logical. FALSE annotation_raster used, otherwise geom_raster()+scale_fill_identity used. Note use scale_fill* addition latter, already requires scale_fill_identity(). nullValue Numeric. Intensity value used NULL layers color compositing. E.g. set g=NULL fix green value 0.5 (defaults 0).","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"Functionality based plotRGB raster package.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"","code":"library(ggplot2) ggRGB(rlogo, r=1, g=2, b=3) ## Define minMax ranges ggRGB(rlogo, r=1,g=2, b=3, limits = matrix(c(100,150,10,200,50,255), ncol = 2, by = TRUE)) ## Perform stong linear contrast stretch ggRGB(rlogo, r = 1, g = 2, b = 3,stretch = \"lin\", quantiles = c(0.2, 0.8)) ## Use only two layers for color calculation ggRGB(rlogo, r = 1, g = 2, b = NULL) ## Return only data.frame df <- ggRGB(rlogo, ggObj = FALSE) head(df) #> x y fill #> 1 0.5 76.5 #FFFFFFFF #> 2 1.5 76.5 #FFFFFFFF #> 3 2.5 76.5 #FFFFFFFF #> 4 3.5 76.5 #FFFFFFFF #> 5 4.5 76.5 #FFFFFFFF #> 6 5.5 76.5 #FFFFFFFF ## Use in layer-mode, e.g. to add to another plot wave <- data.frame(x = c(0, 0:100,100), y = c(0,sin(seq(0,2*pi,pi/50))*10+20, 0)) p <- ggplot(wave, aes(x, y)) p + ggRGB(rlogo, ggLayer = TRUE) + geom_polygon(aes(x, y), fill = \"blue\", alpha = 0.4) + coord_equal(ylim=c(0,75))"},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":null,"dir":"Reference","previous_headings":"","what":"Image to Image Contrast Matching — histMatch","title":"Image to Image Contrast Matching — histMatch","text":"Performs image image contrast adjustments based histogram matching using empirical cumulative distribution functions images.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Image to Image Contrast Matching — histMatch","text":"","code":"histMatch( x, ref, xmask = NULL, refmask = NULL, nSamples = 1e+05, intersectOnly = TRUE, paired = TRUE, forceInteger = FALSE, returnFunctions = FALSE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Image to Image Contrast Matching — histMatch","text":"x SpatRaster. Source raster modified. ref SpatRaster. Reference raster, x matched. xmask RasterLayer SpatRaster. Mask layer x exclude pixels might distort histogram, .e. present ref. NA pixel xmask ignored (maskvalue = NA). refmask RasterLayer SpatRaster. Mask layer ref. NA pixel refmask ignored (maskvalue = NA). nSamples Integer. Number random samples image build histograms. intersectOnly Logical. TRUE sampling take place overlap extent two rasters. Otherwise full rasters used sampling. paired Logical. TRUE corresponding pixels used overlap. forceInteger Logical. Force integer output. returnFunctions Logical. TRUE matching functions returned instead applying x. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Image to Image Contrast Matching — histMatch","text":"SpatRaster x adjusted histogram ref. returnFunctions = TRUE list functions (one layer) returned instead.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Image to Image Contrast Matching — histMatch","text":"x ref must number layers.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Image to Image Contrast Matching — histMatch","text":"Richards Jia: Remote Sensing Digital Image Analysis. Springer, Berlin, Heidelberg, Germany, 439pp.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Image to Image Contrast Matching — histMatch","text":"","code":"library(ggplot2) library(terra) ## Original image a (+1 to prevent log(0)) img_a <- rlogo + 1 ## Degraded image b img_b <- log(img_a) ## Cut-off half the image (just for better display) img_b[, 1:50] <- NA ## Compare Images before histMatching ggRGB(img_a,1,2,3)+ ggRGB(img_b, 1,2,3, ggLayer = TRUE, stretch = \"lin\", q = 0:1) + geom_vline(aes(xintercept = 50))+ ggtitle(\"Img_a vs. Img_b\") #> Warning: data length [3927] is not a sub-multiple or multiple of the number of columns [101] ## Do histogram matching img_b_matched <- histMatch(img_b, img_a) ## Compare Images after histMatching ggRGB(img_a, 1, 2, 3)+ ggRGB(img_b_matched, 1, 2, 3, ggLayer = TRUE, stretch = \"lin\", q = 0:1) + geom_vline(aes(xintercept = 50))+ ggtitle(\"Img_a vs. Img_b_matched\") #> Warning: data length [3927] is not a sub-multiple or multiple of the number of columns [101] ## Histogram comparison opar <- par(mfrow = c(1, 3), no.readonly = TRUE) img_a[,1:50] <- NA redLayers <- c(img_a, img_b, img_b_matched)[[c(1,4,7)]] names(redLayers) <- c(\"img_a\", \"img_b\", \"img_b_matched\") hist(redLayers) ## Reset par par(opar)"},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":null,"dir":"Reference","previous_headings":"","what":"Landsat 5TM Example Data — lsat","title":"Landsat 5TM Example Data — lsat","text":"Subset Landsat 5 TM Scene: LT52240631988227CUB02 Contains seven bands DN format.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Landsat 5TM Example Data — lsat","text":"","code":"lsat"},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Landsat 5TM Example Data — lsat","text":"","code":"ggRGB(lsat, stretch = \"sqrt\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":null,"dir":"Reference","previous_headings":"","what":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"mesma performs spectral mixture anlylsis (SMA) multiple endmember spectral mixture analysis (MESMA) multiband raster image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"","code":"mesma( img, em, method = \"NNLS\", iterate = 400, tolerance = 1e-08, n_models = NULL, sum_to_one = TRUE, ..., verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"img SpatRaster. Remote sensing imagery (usually hyperspectral). em Matrix data.frame spectral endmembers. Columns represent spectral bands (.e. columns correspond number bands img). Rows represent either single endmember per class (SMA) multiple endmembers per class (MESMA), column name class present, containing class name endmember belongs , e.g. \"water\" \"land\". See details . Number rows needs > 1. method Character. Select unmixing method. Currently, \"NNLS\" implemented. Default \"NNLS\". NNLS: applies non-negative least squares (NNLS) regression using sequential coordinate-wise algorithm (SCA) based Franc et al. (2005). iterate Integer. Set maximum iteration per pixel. Processing time increase iterations made possible. Default 400. tolerance Numeric. Tolerance limit representing nearly zero minimal number. Default 1e-8. n_models Logical. applies em contains column class. Defines many endmember combinations picked. Maximum minimum number endmembers class. Defaults amount rows em. sum_to_one Logical. Defines whether sum--one constraint applied probabilities endmember classes sum one (constraint covered NNLS) interpretable fractions. Defaults TRUE. get actual NNLS results, change FALSE. ... arguments passed writeRaster. verbose Logical. Prints progress messages execution.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"SpatRaster. object contain one band per class, value representing estimated probability respective endmember class per pixel, RMSE band. sum_to_one TRUE (default), values class bands can interpreted fractions per endmember class (0 1).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Argument em determines whether SMA (row representing single endmember per class) MESMA (multiple endmembers per class differentiate using class column) computed. multiple endmembers per class provided, mesma compute number SMA (determined argument n_models) multiple endmember combinations drawn em select best fit per pixel based lowest RMSE, based MESMA approach proposed Roberts et al. (1998).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Depending iterate tolerance settings selected endmembers, sum estimated probabilities per pixel varies around 1. NNLS account sum--one constraint. Use sum_to_one sum one post-NNLS. achieve best results, recommended adjust n_models accordance number endemembers per class provided em many endmember combinations possible (endmember used ) computed. models calculated, processing memory recourses needed.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Franc, V., Hlaváč, V., & Navara, M. (2005). Sequential coordinate-wise algorithm non-negative least squares problem. : International Conference Computer Analysis Images Patterns (pp. 407-414). Berlin, Heidelberg. Roberts, D. ., Gardner, M., Church, R., Ustin, S., Scheer, G., & Green, R. O. (1998). Mapping chaparral Santa Monica Mountains using multiple endmember spectral mixture models. Remote sensing environment, 65(3), 267-279.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Jakob Schwalb-Willmann","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"","code":"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) # to perform a MESMA, use multiple endmembers per class, differntiating them # by a column named 'class': if (FALSE) { # \\dontrun{ 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) # 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) } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":null,"dir":"Reference","previous_headings":"","what":"Normalize Raster Images: Center and Scale — normImage","title":"Normalize Raster Images: Center and Scale — normImage","text":"pixel subtracts mean raster layer optionally divide standard deviation.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Normalize Raster Images: Center and Scale — normImage","text":"","code":"normImage(img, norm = TRUE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Normalize Raster Images: Center and Scale — normImage","text":"img SpatRaster. Image transform. Transformation performed separately layer. norm Logical. Perform normalization (scaling) addition centering, .e. divide standard deviation. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Normalize Raster Images: Center and Scale — normImage","text":"Returns SpatRaster number layers input layers layer centered optionally normalized.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Normalize Raster Images: Center and Scale — normImage","text":"","code":"library(terra) ## Load example data ## Normalization: Center and Scale rlogo_center_norm <- normImage(rlogo) hist(rlogo_center_norm) ## Centering rlogo_center <- normImage(rlogo, norm = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":null,"dir":"Reference","previous_headings":"","what":"One-hot encode a raster or vector — oneHotEncode","title":"One-hot encode a raster or vector — oneHotEncode","text":"Splits categorical raster layer (vector) multilayer raster (matrix).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"One-hot encode a raster or vector — oneHotEncode","text":"","code":"oneHotEncode(img, classes, background = 0, foreground = 1, na.rm = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"One-hot encode a raster or vector — oneHotEncode","text":"img SpatRaster integer/numeric vector containing multiple classes classes integer: vector classes extracted background integer: background value (default = 0) foreground integer: foreground value (default = 1) na.rm logical: TRUE, NAs coerced background value. ... arguments passed writeRaster. Ignored img SpatRaster, numeric/integer vector matrix","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"One-hot encode a raster or vector — oneHotEncode","text":"SpatRaster many layers classes. Pixels matching class interest set 1, backround values default set 0 (see background argument)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"One-hot encode a raster or vector — oneHotEncode","text":"","code":"# \\donttest{ sc <- unsuperClass(rlogo, nClasses = 3) ## one-hot encode sc_oneHot <- oneHotEncode(sc$map, classes = c(1,2,3)) ## check results sc_oneHot #> class : SpatRaster #> dimensions : 77, 101, 3 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : c_1, c_2, c_3 #> min values : 0, 0, 0 #> max values : 1, 1, 1 # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":null,"dir":"Reference","previous_headings":"","what":"Pan Sharpen Imagery / Image Fusion — panSharpen","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"provides different methods pan sharpening coarse resolution (typically multispectral) image higher reolution panchromatic image. Values pan-chromatic multispectral images must scale, (e.g. 0:1, DNs 0:255)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"","code":"panSharpen(img, pan, r, g, b, pc = 1, method = \"brovey\", norm = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"img SpatRaster. Coarse resolution multispectral image pan SpatRaster. High resolution image, typically panchromatic. r Character Integer. Red band img. relevant method!='pca' g Character Integer. Green band img. relevant method!='pca' b Character Integer. Blue band img. relevant method!='pca' pc Integer. relevant method = 'pca'. principal component replace. Usually first component (default). first component dominated something else brightness might worth try use second component. method Character. Choose method c(\"pca\", \"ihs\", \"brovey\"). norm Logical. Rescale pan image match 1st PC component. relevant method = 'pca'. TRUE min max matched 1st PC. FALSE pan histogram matched 1st PC.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"pan-sharpened SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"Pan sharpening options: method='pca': Performs pca using rasterPCA. first component swapped pan band PCA rotated backwards. method='ihs': Performs color space transform Intensity-Hue-Saturation space, swaps intensity histogram matched pan backwards transformation. method='brovey': Performs Brovey reweighting. Pan img must value scale (e.g. 0:1, 0:255) otherwise end psychodelic colors.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"","code":"library(terra) library(ggplot2) ## Fake panchromatic image (30m resolution covering ## the visible range (integral from blue to red)) pan <- sum(lsat[[1:3]]) ggR(pan, stretch = \"lin\") ## Fake coarse resolution image (150m spatial resolution) lowResImg <- aggregate(lsat, 5) ## Brovey pan sharpening lowResImg_pan <- panSharpen(lowResImg, pan, r = 3, g = 2, b = 1, method = \"brovey\") lowResImg_pan #> class : SpatRaster #> dimensions : 310, 287, 3 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn_pan, B2_dn_pan, B3_dn_pan #> min values : 47.20757, 18.43627, 11.80072 #> max values : 191.12757, 87.47762, 85.39481 ## Plot ggRGB(lowResImg, stretch = \"lin\") + ggtitle(\"Original\") #> Warning: data length [3534] is not a sub-multiple or multiple of the number of columns [58] ggRGB(lowResImg_pan, stretch=\"lin\") + ggtitle(\"Pansharpened (Brovey)\") #> Warning: data length [88350] is not a sub-multiple or multiple of the number of columns [287]"},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":null,"dir":"Reference","previous_headings":"","what":"Pseudo-Invariant Features based Image Matching — pifMatch","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"Match one scene another based linear regression pseudo-invariant features (PIF).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"","code":"pifMatch( img, ref, method = \"cor\", quantile = 0.95, returnPifMap = TRUE, returnSimMap = TRUE, returnModels = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"img SpatRaster. Image adjusted. ref SpatRaster. Reference image. method Method calculate pixel similarity. Options: euclidean distance ('ed'), spectral angle ('sam') pearson correlation coefficient ('cor'). quantile Numeric. Threshold quantile used identify PIFs returnPifMap Logical. Return binary raster map ot pixels identified pesudo-invariant features. returnSimMap Logical. Return similarity map well returnModels Logical. Return linear models along adjusted image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"Returns List adjusted image intermediate products (requested). img: adjusted image simMap: pixel-wise similarity map (returnSimMap = TRUE) pifMap: binary map pixels selected pseudo-invariant features (returnPifMap = TRUE) models: list linear models; one per layer (returnModels = TRUE)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"function consists three main steps: First, calculates pixel-wise similarity two rasters identifies pseudo-invariant pixels based similarity threshold. second step values pseudo-invariant pixels regressed linear model layer. Finally linear models applied pixels img, thereby matching reference scene. Pixel-wise similarity can calculated using one three methods: euclidean distance (method = \"ed\"), spectral angle (\"sam\") pearsons correlation coefficient (\"cor\"). threshold defined similarity quantile. Setting quantile=0.95 select pixels similarity 95% quantile pseudo-invariant features. Model fitting performed simple linear models (lm); fitting one model per layer.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"","code":"library(terra) ## Create fake example data ## In practice this would be an image from another acquisition date lsat_b <- log(lsat) ## Run pifMatch and return similarity layer, invariant features mask and models lsat_b_adj <- pifMatch(lsat_b, lsat, returnPifMap = TRUE, returnSimMap = TRUE, returnModels = TRUE) # \\donttest{ ## Pixelwise similarity ggR(lsat_b_adj$simMap, geom_raster = TRUE) ## Pesudo invariant feature mask ggR(lsat_b_adj$pifMap) ## Histograms of changes par(mfrow=c(1,3)) hist(lsat_b[[1]], main = \"lsat_b\") hist(lsat[[1]], main = \"reference\") hist(lsat_b_adj$img[[1]], main = \"lsat_b adjusted\") ## Model summary for first band summary(lsat_b_adj$models[[1]]) #> #> Call: #> lm(formula = ref ~ img, data = df) #> #> Residuals: #> Min 1Q Median 3Q Max #> -3.3904 -0.6021 0.0163 0.7107 24.6845 #> #> Coefficients: #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -324.9027 0.9321 -348.6 <2e-16 *** #> img 92.9473 0.2184 425.5 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 1.373 on 4447 degrees of freedom #> Multiple R-squared: 0.976,\tAdjusted R-squared: 0.976 #> F-statistic: 1.811e+05 on 1 and 4447 DF, p-value: < 2.2e-16 #> # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling `rhs(lhs)`.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"applies kmeans cluster model pixels raster. Useful want apply kmeans model scene scene B.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"","code":"# S3 method for class 'unsuperClass' predict(object, img, output = \"classes\", ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"object unsuperClass object img Raster object. Layernames must correspond layernames used train superClass model, .e. layernames original raster image. output Character. Either 'classes' (kmeans class; default) 'distances' (euclidean distance cluster center). ... arguments passed writeRaster, e.g. filename","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"Returns raster K-means distances base object passed arguments.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"","code":"## Load training data ## Perform unsupervised classification uc <- unsuperClass(rlogo, nClasses = 10) ## Apply the model to another raster map <- predict(uc, rlogo)"},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":null,"dir":"Reference","previous_headings":"","what":"Radiometric Calibration and Correction — radCor","title":"Radiometric Calibration and Correction — radCor","text":"Implements several different methods radiometric calibration correction Landsat data. can either specify metadata file, supply neccesary values manually. proper parametrization apref sdos work sensors well.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Radiometric Calibration and Correction — radCor","text":"","code":"radCor( img, metaData, method = \"apref\", bandSet = \"full\", hazeValues, hazeBands, atmosphere, darkProp = 0.01, clamp = TRUE, verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Radiometric Calibration and Correction — radCor","text":"img SpatRaster metaData object class ImageMetaData path meta data (MTL) file. method Radiometric conversion/correction method used. currently four methods available (see Details): \"rad\", \"apref\", \"sdos\", \"dos\", \"costz\". bandSet Numeric character. original Landsat band numbers names form (\"B1\", \"B2\" etc). set 'full' bands solar (optical) region processed. hazeValues Numeric. Either vector dark DNs per hazeBand (method = 'sdos'); possibly estimated using estimateHaze. 'starting haze value' (DN) relative scattering models method = 'dos' 'costz'. provided, hazeValues estimated automated fashion hazeBands. Argument applies methods 'sdos', 'dos' 'costz'. hazeBands Character integer. Bands corresponding hazeValues (method = 'sdos') band select starting haze value ('dos' 'costz'). atmosphere Character. Atmospheric characteristics. estimated expicilty provided. Must one \"veryClear\", \"clear\", \"moderate\", \"hazy\" \"veryHazy\". darkProp Numeric. Estimated proportion dark pixels scene. Used automatic guessing hazeValues (typically one choose 1 2%). clamp Logical. Enforce valid value range. default reflectance forced stay within [0,1] radiance >= 0 replacing invalid values correspinding boundary, e.g. -0.1 become 0. verbose Logical. Print status information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Radiometric Calibration and Correction — radCor","text":"SpatRaster top--atmosphere radiance (\\(W/(m^2 * srad * \\mu m)\\)), -satellite brightness temperature (K), top--atmosphere reflectance (unitless) corrected sun angle -surface reflectance (unitless).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Radiometric Calibration and Correction — radCor","text":"atmospheric correction methods (sdos, dos costz) apply optical (solar) region spectrum affect thermal band. Dark object subtraction approaches rely estimation atmospheric haze based *dark* pixels. Dark pixels assumed zero reflectance, hence name. assumed radiation originating *dark* pixels due atmospheric haze reflectance surface . folloiwing methods available: either \"dos\" \"costz\" selected, radCor use atmospheric haze decay model described Chavez (1989). Depending atmosphere following coefficients used: Landsat 8, values extra-terrestrial irradiation (esun) provided NASA. , however, neccessary DOS-based approaches. Therefore, values derived standard reference spectrum published Thuillier et al. (2003) using Landsat 8 OLI spectral response functions implemented sun-earth distances neglect earth's eccentricity. Instead use 100 year daily average (1979-2070).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Radiometric Calibration and Correction — radCor","text":"originally fork randcorr() function landsat package. version works SpatRasters hence suitable large rasters.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Radiometric Calibration and Correction — radCor","text":"S. Goslee (2011): Analyzing Remote Sensing Data R: landsat Package. Journal Statistical Software 43(4). G. Thuillier et al. (2003) SOLAR SPECTRAL IRRADIANCE 200 2400 nm MEASURED SOLSPEC SPECTROMETER ATLAS EURECA MISSIONS. Solar Physics 214(1): 1-22 (","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Radiometric Calibration and Correction — radCor","text":"","code":"library(terra) ## Import meta-data and bands based on MTL file mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) ## Convert DN to top of atmosphere reflectance and brightness temperature lsat_ref <- radCor(lsat_t, metaData = metaData, method = \"apref\") ## Correct DN to at-surface-reflecatance with DOS (Chavez decay model) lsat_sref <- radCor(lsat_t, metaData = metaData) ## Correct DN to at-surface-reflecatance with simple DOS ## Automatic haze estimation hazeDN <- estimateHaze(lsat_t, hazeBands = 1:4, darkProp = 0.01, plot = FALSE) lsat_sref <- radCor(lsat_t, metaData = metaData, method = \"sdos\", hazeValues = hazeDN, hazeBands = 1:4)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":null,"dir":"Reference","previous_headings":"","what":"Change Vector Analysis — rasterCVA","title":"Change Vector Analysis — rasterCVA","text":"Calculates angle magnitude change vectors. Dimensionality limited two bands per image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change Vector Analysis — rasterCVA","text":"","code":"rasterCVA(x, y, tmf = NULL, nct = NULL, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change Vector Analysis — rasterCVA","text":"x SpatRaster two layers. reference/origin change calculations. rasters (y y) need correspond , .e. resolution, extent origin. y SpatRaster two layers. rasters (y y) need correspond , .e. resolution, extent origin. tmf Numeric. Threshold median factor (optional). Used calculate threshold magnitude pixels considered stable, .e. change. Calculated tmf * mean(magnitude[magnitude > 0]). nct Numeric. -change threshold (optional). Alternative tmf. Sets absolute threshold. Change magnitudes nct considered stable set NA. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Change Vector Analysis — rasterCVA","text":"Returns SpatRaster two layers: change vector angle change vector magnitude","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Change Vector Analysis — rasterCVA","text":"Change Vector Analysis (CVA) used identify spectral changes two identical scenes acquired different times. CVA limited two bands per image. pixel calculates change vector two-dimensional spectral space. example given pixel image B red nir band change vector calculated coordinate pairs: (red_A | nir_A) (red_B | nir_B). coordinate system defined order input bands: first band defines x-axis second band y-axis, respectively. Angles returned *degree* beginning 0 degrees pointing 'north', .e. y-axis, .e. second band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change Vector Analysis — rasterCVA","text":"","code":"library(terra) pca <- rasterPCA(lsat)$map ## Do change vector analysis cva <- rasterCVA(pca[[1:2]], pca[[3:4]]) cva #> class : SpatRaster #> dimensions : 310, 287, 2 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : angle, magnitude #> min values : 5.423571e-03, 0.1009387 #> max values : 3.599993e+02, 106.5000918"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-layer Pixel Entropy — rasterEntropy","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"Shannon entropy calculated pixel based layer values. used categorical / integer valued rasters.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"","code":"rasterEntropy(img, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"img SpatRaster ... additional arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"SpatRaster \"entropy\"","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"Entropy calculated -sum(p log(p)); p class frequency per pixel.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"","code":"re <- rasterEntropy(rlogo) ggR(re, geom_raster = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":null,"dir":"Reference","previous_headings":"","what":"Principal Component Analysis for Rasters — rasterPCA","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Calculates R-mode PCA SpatRasters returns SpatRaster multiple layers PCA scores.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Principal Component Analysis for Rasters — rasterPCA","text":"","code":"rasterPCA( img, nSamples = NULL, nComp = nlyr(img), spca = FALSE, maskCheck = TRUE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Principal Component Analysis for Rasters — rasterPCA","text":"img SpatRaster. nSamples Integer NULL. Number pixels sample PCA fitting. NULL, pixels used. nComp Integer. Number PCA components return. spca Logical. TRUE, perform standardized PCA. Corresponds centered scaled input image. usually beneficial equal weighting layers. (FALSE default) maskCheck Logical. Masks pixels least one NA (default TRUE reccomended introduces slow-, see Details wise disable maskCheck). Takes effect nSamples NULL. ... arguments passed writeRaster, e.g. filename.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Returns named list containing PCA model object ($model) SpatRaster principal component layers ($object).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Internally rasterPCA relies use princomp (R-mode PCA). nSamples given PCA calculated based random sample pixels predicted full raster. nSamples NULL covariance matrix calculated first used calculate princomp predict full raster. latter precise, since considers pixels, however, may slower calculating PCA subset pixels. Pixels missing values one bands set NA. built-check pixels can lead slow-rasterPCA. However, make sure know beforehand pixels either valid values NAs throughout layers can disable check setting maskCheck=FALSE speeds computation. Standardised PCA (SPCA) can useful imagery bands different dynamic ranges combined. SPC uses correlation matrix instead covariance matrix, effect using normalised bands unit variance.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Principal Component Analysis for Rasters — rasterPCA","text":"","code":"library(ggplot2) library(reshape2) ggRGB(rlogo, 1,2,3) ## Run PCA set.seed(25) rpc <- rasterPCA(rlogo) rpc #> $call #> rasterPCA(img = rlogo) #> #> $model #> Call: #> princomp(cor = spca, covmat = covMat) #> #> Standard deviations: #> Comp.1 Comp.2 Comp.3 #> 124.814772 17.084151 1.456423 #> #> 3 variables and 7777 observations. #> #> $map #> class : SpatRaster #> dimensions : 77, 101, 3 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : PC1, PC2, PC3 #> min values : -323.1956, -46.42416, -9.374094 #> max values : 118.2781, 26.11958, 6.362937 #> #> attr(,\"class\") #> [1] \"rasterPCA\" \"RStoolbox\" ## Model parameters: summary(rpc$model) #> Importance of components: #> Comp.1 Comp.2 Comp.3 #> Standard deviation 124.8147718 17.08415063 1.456422555 #> Proportion of Variance 0.9814783 0.01838804 0.000133636 #> Cumulative Proportion 0.9814783 0.99986636 1.000000000 loadings(rpc$model) #> #> Loadings: #> Comp.1 Comp.2 Comp.3 #> red 0.594 0.507 0.625 #> green 0.585 0.262 -0.768 #> blue 0.553 -0.821 0.141 #> #> Comp.1 Comp.2 Comp.3 #> SS loadings 1.000 1.000 1.000 #> Proportion Var 0.333 0.333 0.333 #> Cumulative Var 0.333 0.667 1.000 ggRGB(rpc$map,1,2,3, stretch=\"lin\", q=0) if(require(gridExtra)){ plots <- lapply(1:3, function(x) ggR(rpc$map, x, geom_raster = TRUE)) grid.arrange(plots[[1]],plots[[2]], plots[[3]], ncol=2) } #> Loading required package: gridExtra"},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy import tool for EarthExplorer .csv export files — readEE","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"Imports tidies CSV files exported EarthExplorer data.frames annotates missing fields.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"","code":"readEE(x)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"x Character, Character list. One paths EarthExplorer export files.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"data.frame","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"EarthExplorer CSV file can produced search results page. results click 'export results' select 'comma (,) delimited'. Note subset columns imported deemed interesting. Please contact maintainer think omited column included.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"","code":"library(ggplot2) ee <- readEE(system.file(\"external/EarthExplorer_LS8.txt\", package = \"RStoolbox\")) ## Scenes with cloud cover < 20% ee[ee$Cloud.Cover < 20,] #> Landsat.Scene.Identifier WRS.Path WRS.Row Data.Category Cloud.Cover #> 6 LC82240632015157LGN00 224 63 NOMINAL 13.20 #> 27 LC82240632014186LGN00 224 63 NOMINAL 15.94 #> 40 LC82240632013327LGN00 224 63 NOMINAL 13.19 #> 46 LC82240632013215LGN00 224 63 NOMINAL 14.72 #> 49 LC82240632013167LGN00 224 63 NOMINAL 6.35 #> Station.Identifier Day.Night Data.Type.Level.1 Date.Acquired Sun.Elevation #> 6 LGN DAY L1T 2015/06/06 51.98871 #> 27 LGN DAY L1T 2014/07/05 51.01591 #> 40 LGN DAY L1GT 2013/11/23 61.83434 #> 46 LGN DAY L1T 2013/08/03 54.43226 #> 49 LGN DAY L1T 2013/06/16 51.64735 #> Sun.Azimuth Geometric.RMSE.Model.X Geometric.RMSE.Model.Y #> 6 43.59274 6.244 5.663 #> 27 44.79093 5.452 5.420 #> 40 126.95937 0.000 0.000 #> 46 51.68815 5.631 5.840 #> 49 42.59918 6.377 5.862 #> Display.ID Ordering.ID #> 6 LC82240632015157LGN00 LC82240632015157LGN00 #> 27 LC82240632014186LGN00 LC82240632014186LGN00 #> 40 LC82240632013327LGN00 LC82240632013327LGN00 #> 46 LC82240632013215LGN00 LC82240632013215LGN00 #> 49 LC82240632013167LGN00 LC82240632013167LGN00 #> Download.Link #> 6 http://earthexplorer.usgs.gov/download/options/4923/LC82240632015157LGN00 #> 27 http://earthexplorer.usgs.gov/download/options/4923/LC82240632014186LGN00 #> 40 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013327LGN00 #> 46 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013215LGN00 #> 49 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013167LGN00 #> Browse.Link Date Doy Year Satellite Num #> 6 NA 2015-06-06 157 2015 LS8 8 #> 27 NA 2014-07-05 186 2014 LS8 8 #> 40 NA 2013-11-23 327 2013 LS8 8 #> 46 NA 2013-08-03 215 2013 LS8 8 #> 49 NA 2013-06-16 167 2013 LS8 8 ## Available time-series ggplot(ee) + geom_segment(aes(x = Date, xend = Date, y = 0, yend = 100 - Cloud.Cover, col = as.factor(Year))) + scale_y_continuous(name = \"Scene quality (% clear sky)\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Read Landsat MTL metadata files — readMeta","title":"Read Landsat MTL metadata files — readMeta","text":"Reads metadata deals legacy versions Landsat metadata files possible adds missing information (radiometric gain offset, earth-sun distance).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read Landsat MTL metadata files — readMeta","text":"","code":"readMeta(file, raw = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read Landsat MTL metadata files — readMeta","text":"file path Landsat MTL file (...MTL.txt) raw Logical. TRUE full raw metadata returned list. FALSE (default) important metadata homogenized standard format (ImageMetaData) information added.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read Landsat MTL metadata files — readMeta","text":"Object class ImageMetaData","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read Landsat MTL metadata files — readMeta","text":"","code":"## Example metadata file (MTL) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") ## Read metadata metaData <- readMeta(mtlFile) ## Summary summary(metaData) #> Scene: LT52240631988227CUB02 #> Satellite: LANDSAT5 #> Sensor: TM #> Date: 1988-08-14 #> Path/Row: 224/63 #> Projection: +proj=utm +zone=22 +units=m +datum=WGS84 +ellips=WGS84 #> Scene: PROJCRS[\"unknown\", #> BASEGEOGCRS[\"unknown\", #> DATUM[\"World Geodetic System 1984\", #> ELLIPSOID[\"WGS 84\",6378137,298.257223563, #> LENGTHUNIT[\"metre\",1]], #> ID[\"EPSG\",6326]], #> PRIMEM[\"Greenwich\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8901]]], #> CONVERSION[\"UTM zone 22N\", #> METHOD[\"Transverse Mercator\", #> ID[\"EPSG\",9807]], #> PARAMETER[\"Latitude of natural origin\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8801]], #> PARAMETER[\"Longitude of natural origin\",-51, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8802]], #> PARAMETER[\"Scale factor at natural origin\",0.9996, #> SCALEUNIT[\"unity\",1], #> ID[\"EPSG\",8805]], #> PARAMETER[\"False easting\",500000, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8806]], #> PARAMETER[\"False northing\",0, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8807]], #> ID[\"EPSG\",16022]], #> CS[Cartesian,2], #> AXIS[\"(E)\",east, #> ORDER[1], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]], #> AXIS[\"(N)\",north, #> ORDER[2], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]]] #> #> Data: #> FILES QUANTITY CATEGORY #> B1_dn LT52240631988227CUB02_B1.TIF dn image #> B2_dn LT52240631988227CUB02_B2.TIF dn image #> B3_dn LT52240631988227CUB02_B3.TIF dn image #> B4_dn LT52240631988227CUB02_B4.TIF dn image #> B5_dn LT52240631988227CUB02_B5.TIF dn image #> B6_dn LT52240631988227CUB02_B6.TIF dn image #> B7_dn LT52240631988227CUB02_B7.TIF dn image #> #> Available calibration parameters (gain and offset): #> \tdn -> radiance (toa) #> \tdn -> brightness temperature (toa) #>"},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":null,"dir":"Reference","previous_headings":"","what":"Read ENVI spectral libraries — readSLI","title":"Read ENVI spectral libraries — readSLI","text":"read/write support ENVI spectral libraries","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read ENVI spectral libraries — readSLI","text":"","code":"readSLI(path)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read ENVI spectral libraries — readSLI","text":"path Path spectral library file ending .sli.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read ENVI spectral libraries — readSLI","text":"spectral libraries read data.frame. first column contains wavelengths remaining columns contain spectra.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read ENVI spectral libraries — readSLI","text":"ENVI spectral libraries consist binary data file (.sli) corresponding header (.hdr, .sli.hdr) file.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read ENVI spectral libraries — readSLI","text":"","code":"## Example data sliFile <- system.file(\"external/vegSpec.sli\", package=\"RStoolbox\") sliTmpFile <- paste0(tempdir(),\"/vegetationSpectra.sli\") ## Read spectral library sli <- readSLI(sliFile) head(sli) #> wavelength veg_stressed veg_vital #> 1 350 0.008958003 0.008836994 #> 2 351 0.008910760 0.008909440 #> 3 352 0.008874181 0.008972186 #> 4 353 0.008847097 0.009025744 #> 5 354 0.008829174 0.009071405 #> 6 355 0.008819440 0.009109739 plot(sli[,1:2], col = \"orange\", type = \"l\") lines(sli[,c(1,3)], col = \"green\") ## Write to binary spectral library writeSLI(sli, path = sliTmpFile)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Image Rescaling — rescaleImage","title":"Linear Image Rescaling — rescaleImage","text":"performs linear shifts value ranges either match min/max another image (y) min max value (ymin ymax).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Image Rescaling — rescaleImage","text":"","code":"rescaleImage(x, y, xmin, xmax, ymin, ymax, forceMinMax = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Image Rescaling — rescaleImage","text":"x SpatRaster numeric vector. Image normalise. y SpatRaster numeric vector. Reference image. Optional. Used extract min max values ymin ymax missing. xmin Numeric. Min value x. Either single value one value per layer x. xmin provided extracted x. xmax Numeric. Max value x. Either single value one value per layer x. xmax provided extracted x. ymin Numeric. Min value y. Either single value one value per layer x. ymin provided extracted y. ymax Numeric. Max value y. Either single value one value per layer x. ymax provided extracted y. forceMinMax Logical. Forces update min max data slots x y. ... additional arguments passed terra::writeRaster()","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Image Rescaling — rescaleImage","text":"Returns SpatRaster dimensions input raster x shifted stretched new limits.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Image Rescaling — rescaleImage","text":"Providing xmin xmax values manually can useful raster contains variable known, fixed value range, e.g. NDVI -1 1 actual pixel values encompass entire range. providing xmin = -1 xmax = 1 values can rescaled range, e.g. 1 100 comparability rescaled NDVI scenes retained.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Image Rescaling — rescaleImage","text":"","code":"lsat2 <- lsat - 1000 lsat2 #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : -946, -982, -989, -996, -998, -869, ... #> max values : -815, -913, -908, -873, -852, -854, ... ## Rescale lsat2 to match original lsat value range lsat2_rescaled <- rescaleImage(lsat2, lsat) lsat2_rescaled #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 54, 18, 11, 4, 2, 131, ... #> max values : 185, 87, 92, 127, 148, 146, ... ## Rescale lsat to value range [0,1] lsat2_unity <- rescaleImage(lsat2, ymin = 0, ymax = 1) lsat2_unity #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 0, 0, 0, 0, 0, 0, ... #> max values : 1, 1, 1, 1, 1, 1, ..."},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":null,"dir":"Reference","previous_headings":"","what":"Rlogo as SpatRaster — rlogo","title":"Rlogo as SpatRaster — rlogo","text":"Tiny example raster data used run examples.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rlogo as SpatRaster — rlogo","text":"","code":"rlogo"},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rlogo as SpatRaster — rlogo","text":"","code":"ggRGB(rlogo,r = 1,g = 2,b = 3)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Set global options for RStoolbox — rsOpts","title":"Set global options for RStoolbox — rsOpts","text":"shortcut options(RStoolbox.*)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set global options for RStoolbox — rsOpts","text":"","code":"rsOpts(verbose = NULL, idxdb = NULL)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set global options for RStoolbox — rsOpts","text":"verbose Logical. TRUE many functions print status messages current processing step. default verbose mode disabled. idxdb List. list conatins formal calculation spectral indices. Modify list pipe spectral index internal C++ calculation RStoolbox.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set global options for RStoolbox — rsOpts","text":"return, just setter verbosiness index-database RStoolbox package. latter, see example Rstoolbox::spectralIndices()","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set global options for RStoolbox — rsOpts","text":"","code":"rsOpts(verbose=TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":null,"dir":"Reference","previous_headings":"","what":"Spectral Angle Mapper — sam","title":"Spectral Angle Mapper — sam","text":"Calculates angle spectral space pixels set reference spectra (endmembers) image classification based spectral similarity.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spectral Angle Mapper — sam","text":"","code":"sam(img, em, angles = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spectral Angle Mapper — sam","text":"img SpatRaster. Remote sensing imagery. em Matrix data.frame endmembers. row contain endmember spectrum class, .e. columns correspond bands img. reccomended set rownames class names. angles Logical. TRUE RasterBrick containing one layer per endmember returned containing spectral angles. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spectral Angle Mapper — sam","text":"SpatRaster angles = FALSE single Layer returned pixel assigned closest endmember class (integer pixel values correspond row order em.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spectral Angle Mapper — sam","text":"pixel spectral angle mapper calculates angle vector defined pixel values endmember vector. result one raster layer endmember containing spectral angle. smaller spectral angle similar pixel given endmember class. second step one can go ahead enforce thresholds maximum angles simply classify pixel similar endmember.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spectral Angle Mapper — sam","text":"","code":"library(terra) library(ggplot2) ## Sample endmember spectra ## First location is water, second is open agricultural vegetation pts <- data.frame(x = c(624720, 627480), y = c(-414690, -411090)) endmembers <- extract(lsat, pts) rownames(endmembers) <- c(\"water\", \"vegetation\") ## Calculate spectral angles lsat_sam <- sam(lsat, endmembers, angles = TRUE) plot(lsat_sam) ## Classify based on minimum angle lsat_sam <- sam(lsat, endmembers, angles = FALSE) ggR(lsat_sam, forceCat = TRUE, geom_raster=TRUE) + scale_fill_manual(values = c(\"blue\", \"green\"), labels = c(\"water\", \"vegetation\"))"},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":null,"dir":"Reference","previous_headings":"","what":"Save and Read RStoolbox Classification Results — saveRSTBX","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"Saves objects classes unsuperClass, superClass, rasterPCA fCover file. Useful archive fitted models.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"","code":"saveRSTBX(x, filename, format = \"raster\", ...) readRSTBX(filename)"},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"x RStoolbox object classes c(\"fCover\", \"rasterPCA\", \"superClass\", \"unsuperClass\") filename Character. Path filename. file extension ignored. format Character. Driver use raster file ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"output writeRSTBX least two files written disk: ) .rds file containing object b) raster file (depending driver choose can two files).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"saveRSTBX(): Save RStoolbox object file readRSTBX(): Read files saved saveRSTBX","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"files must kept directory read full object back R means readRSTBX. can move another location move ** (just like Shapefiles). case raster file(s) missing, readRSTBX still return object raster missing. writeRSTBX readRSTBX convenience wrappers around saveRDS, readRDS. means can read files created way also base functionality long move files. x$map SpatRaster object hence contains static link file disk.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"","code":"if (FALSE) { # \\dontrun{ input <- rlogo ## Create filename file <- paste0(tempdir(), \"/test\", runif(1)) ## Run PCA rpc <- rasterPCA(input, nSample = 100) ## Save object saveRSTBX(rpc, filename=file) ## Which files were written? list.files(tempdir(), pattern = basename(file)) ## Re-read files re_rpc <- readRSTBX(file) ## Remove files file.remove(list.files(tempdir(), pattern = basename(file), full = TRUE)) } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":null,"dir":"Reference","previous_headings":"","what":"Sentinel 2 MSI L2A Scene — sen2","title":"Sentinel 2 MSI L2A Scene — sen2","text":"Contains 13 bands already converted spectral reflectances","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sentinel 2 MSI L2A Scene — sen2","text":"","code":"sen2"},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sentinel 2 MSI L2A Scene — sen2","text":"","code":"ggRGB(sen2, r=4, g=3, b=2, stretch = \"lin\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":null,"dir":"Reference","previous_headings":"","what":"Spectral Indices — spectralIndices","title":"Spectral Indices — spectralIndices","text":"Calculate suite multispectral indices NDVI, SAVI etc. efficient way via C++.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spectral Indices — spectralIndices","text":"","code":"spectralIndices( img, blue = NULL, green = NULL, red = NULL, nir = NULL, redEdge1 = NULL, redEdge2 = NULL, redEdge3 = NULL, swir1 = NULL, swir2 = NULL, swir3 = NULL, scaleFactor = 1, skipRefCheck = FALSE, indices = NULL, index = NULL, maskLayer = NULL, maskValue = 1, coefs = list(L = 0.5, G = 2.5, L_evi = 1, C1 = 6, C2 = 7.5, s = 1, swir2ccc = NULL, swir2coc = NULL), ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spectral Indices — spectralIndices","text":"img SpatRaster. Typically remote sensing imagery, classified. blue Character integer. Blue band. green Character integer. Green band. red Character integer. Red band. nir Character integer. Near-infrared band (700-1100nm). redEdge1 Character integer. Red-edge band (705nm) redEdge2 Character integer. Red-edge band (740nm) redEdge3 Character integer. Red-edge band (783nm) swir1 used swir2 Character integer. Short-wave-infrared band (1400-1800nm). swir3 Character integer. Short-wave-infrared band (2000-2500nm). scaleFactor Numeric. Scale factor conversion scaled reflectances [0,1] value range (applied reflectance/scaleFactor) Neccesary calculating EVI/EVI2 scaled reflectance values. skipRefCheck Logical. EVI/EVI2 calculated rough heuristic check, whether data inside [0,1]+/-0.5 (applying potential scaleFactor). invalid reflectances, e.g. clouds reflectance > 1 check result false positive skip EVI calculation. Use argument skip check cases *iff* sure data scaleFactor valid. indices Character. One spectral indices calculate (see Details). default (NULL) implemented indices given spectral bands provided calculated. index Character. Alias indices. maskLayer RasterLayer SpatRaster containing mask, e.g. clouds, pixels set NA. Alternatively layername -number can provided mask part img. maskValue Integer. Pixel value maskLayer masked output, .e. set NA calculated indices. coefs List coefficients (see Details). ... arguments filename etc. passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spectral Indices — spectralIndices","text":"SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spectral Indices — spectralIndices","text":"spectralIndices calculates indices one go C++, efficient calculating index separately (large rasters). default indices can calculated given specified indices calculated. want indices, use indices argument specify exactly indices calculated. See table bellow index names required bands. Index values outside valid value ranges (range exists) set NA. example pixel NDVI > 1 set NA. indices require additional parameters, slope soil line specified via list coefs argument. Although defaults sensible values, values like soil brightnes factor L SAVI adapted depending characteristics scene. coefficients : wavelength band names defined following Schowengertd 2007, p10. last column shows exemplarily Landsat 5 TM bands correspond wavelength range definition.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spectral Indices — spectralIndices","text":"","code":"library(ggplot2) library(terra) ## Calculate NDVI ndvi <- spectralIndices(lsat, red = \"B3_dn\", nir = \"B4_dn\", indices = \"NDVI\") ndvi #> class : SpatRaster #> dimensions : 310, 287, 1 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> name : NDVI #> min value : -0.5789474 #> max value : 0.7629630 ggR(ndvi, geom_raster = TRUE) + scale_fill_gradientn(colours = c(\"black\", \"white\")) # \\donttest{ ## Calculate all possible indices, given the provided bands ## Convert DNs to reflectance (required to calculate EVI and EVI2) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") lsat_ref <- radCor(lsat, mtlFile, method = \"apref\") #> 15:22:27 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn #> 15:22:27 | Thermal bands to convert to brightness temperature: B6_dn #> 15:22:27 | Processing thermal band(s) #> 15:22:27 | Processing radiance / reflectance SI <- spectralIndices(lsat_ref, red = \"B3_tre\", nir = \"B4_tre\") plot(SI) ## Custom Spectral Index Calculation (beta) (supports only bands right now...) # Get all indices idxdb <- getOption(\"RStoolbox.idxdb\") # Cutomize the RStoolbox index-database and overwrite the option cdb <- c(idxdb, CUSTOM = list( list(c(\"Mueller2024\", \"Super custom index\"), function(blue, red) {blue + red}))) rsOpts(idxdb = cdb) # Calculate the custom index, (also together with the provided ones) custom_ind <- spectralIndices(lsat, blue = 1, red = 3, nir = 4, indices = c(\"NDVI\", \"CUSTOM\")) # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":null,"dir":"Reference","previous_headings":"","what":"SRTM Digital Elevation Model — srtm","title":"SRTM Digital Elevation Model — srtm","text":"DEM Landsat example area taken SRTM v3 tile: s04_w050_1arc_v3.tif","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SRTM Digital Elevation Model — srtm","text":"","code":"srtm"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SRTM Digital Elevation Model — srtm","text":"","code":"ggR(srtm)"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":null,"dir":"Reference","previous_headings":"","what":"SRTM scene for the sen2 exemplary scene — srtm_sen2","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"DEM Sentinel 2 example area taken SRTM v4","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"","code":"srtm_sen2"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"","code":"ggR(srtm_sen2)"},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Import separate Landsat files into single stack — stackMeta","title":"Import separate Landsat files into single stack — stackMeta","text":"Reads Landsat MTL XML metadata files loads single Landsat Tiffs rasterStack. aware default stackMeta() import panchromatic bands thermal bands resolutions != 30m.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import separate Landsat files into single stack — stackMeta","text":"","code":"stackMeta(file, quantity = \"all\", category = \"image\", allResolutions = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import separate Landsat files into single stack — stackMeta","text":"file Character. Path Landsat MTL metadata (*_MTL.txt) file Landsat CDR xml metadata file (*.xml). quantity Character vector. quantity returned. Options: digital numbers ('dn'), top atmosphere reflectance ('tre'), surface reflectance ('sre'), brightness temperature ('bt'), spectral index ('index'), quantities (''). category Character vector. category data return. Options 'image': image data, 'pan': panchromatic image, 'index': multiband indices, 'qa' quality flag bands, '': categories. allResolutions Logical. TRUE list returned length = unique spatial resolutions. argument introduced maintain backward compatibility switched TRUE upcoming release. Please base new code terra.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Import separate Landsat files into single stack — stackMeta","text":"Returns one single SpatRaster comprising requested bands. allResolutions = TRUE ** different resolution layers (e.g. 15m panchromatic band along wit 30m imagery) list RasterStacks returned.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Import separate Landsat files into single stack — stackMeta","text":"aware default stackMeta() import panchromatic bands thermal bands resolutions != 30m. Use allResolutions argument import layers. Note nowadays USGS uses cubic convolution resample TIR bands 30m resolution.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Import separate Landsat files into single stack — stackMeta","text":"","code":"## Example metadata file (MTL) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") ## Read metadata metaData <- readMeta(mtlFile) summary(metaData) #> Scene: LT52240631988227CUB02 #> Satellite: LANDSAT5 #> Sensor: TM #> Date: 1988-08-14 #> Path/Row: 224/63 #> Projection: +proj=utm +zone=22 +units=m +datum=WGS84 +ellips=WGS84 #> Scene: PROJCRS[\"unknown\", #> BASEGEOGCRS[\"unknown\", #> DATUM[\"World Geodetic System 1984\", #> ELLIPSOID[\"WGS 84\",6378137,298.257223563, #> LENGTHUNIT[\"metre\",1]], #> ID[\"EPSG\",6326]], #> PRIMEM[\"Greenwich\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8901]]], #> CONVERSION[\"UTM zone 22N\", #> METHOD[\"Transverse Mercator\", #> ID[\"EPSG\",9807]], #> PARAMETER[\"Latitude of natural origin\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8801]], #> PARAMETER[\"Longitude of natural origin\",-51, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8802]], #> PARAMETER[\"Scale factor at natural origin\",0.9996, #> SCALEUNIT[\"unity\",1], #> ID[\"EPSG\",8805]], #> PARAMETER[\"False easting\",500000, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8806]], #> PARAMETER[\"False northing\",0, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8807]], #> ID[\"EPSG\",16022]], #> CS[Cartesian,2], #> AXIS[\"(E)\",east, #> ORDER[1], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]], #> AXIS[\"(N)\",north, #> ORDER[2], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]]] #> #> Data: #> FILES QUANTITY CATEGORY #> B1_dn LT52240631988227CUB02_B1.TIF dn image #> B2_dn LT52240631988227CUB02_B2.TIF dn image #> B3_dn LT52240631988227CUB02_B3.TIF dn image #> B4_dn LT52240631988227CUB02_B4.TIF dn image #> B5_dn LT52240631988227CUB02_B5.TIF dn image #> B6_dn LT52240631988227CUB02_B6.TIF dn image #> B7_dn LT52240631988227CUB02_B7.TIF dn image #> #> Available calibration parameters (gain and offset): #> \tdn -> radiance (toa) #> \tdn -> brightness temperature (toa) #> ## Load rasters based on metadata file lsat <- stackMeta(mtlFile) lsat #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / UTM zone 22N (EPSG:32622) #> sources : LT52240631988227CUB02_B1.TIF #> LT52240631988227CUB02_B2.TIF #> LT52240631988227CUB02_B3.TIF #> ... and 4 more source(s) #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 54, 18, 11, 4, 2, 131, ... #> max values : 185, 87, 92, 127, 148, 146, ..."},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Supervised Classification — superClass","title":"Supervised Classification — superClass","text":"Supervised classification classification regression mode based vector training data (points polygons).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Supervised Classification — superClass","text":"","code":"superClass( img, trainData, valData = NULL, responseCol = NULL, nSamples = 1000, nSamplesV = 1000, polygonBasedCV = FALSE, trainPartition = NULL, model = \"rf\", tuneLength = 3, kfold = 5, minDist = 2, mode = \"classification\", predict = TRUE, predType = \"raw\", filename = NULL, verbose, overwrite = TRUE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Supervised Classification — superClass","text":"img SpatRaster. Typically remote sensing imagery, classified. trainData sf sp spatial vector data containing training locations (POINTs,POLYGONs). valData Ssf sp spatial vector data containing validation locations (POINTs,POLYGONs) (optional). responseCol Character integer giving column trainData, contains response variable. Can omitted, trainData one column. nSamples Integer. Number samples per land cover class. NULL pixels covered training polygons used (memory intensive!). Ignored trainData consists POINTs. nSamplesV Integer. Number validation samples per land cover class. NULL pixels covered validation polygons used (memory intensive!). Ignored valData consists POINTs. polygonBasedCV Logical. TRUE model tuning cross-validation conducted per-polygon basis. Use deal overfitting issues. affect training data supplied SpatialPointsDataFrames. trainPartition Numeric. Partition (polygon based) trainData goes training data set zero one. Ignored valData provided. model Character. model use. See train options. Defaults randomForest ('rf'). addition standard caret models, maximum likelihood classification available via model = 'mlc'. tuneLength Integer. Number levels tuning parameter (see train details). kfold Integer. Number cross-validation resamples model tuning. minDist Numeric. Minumum distance training validation data, e.g. minDist=1 clips validation polygons ensure minimal distance one pixel (pixel size according img) next training polygon. Requires data carry valid projection information. mode Character. Model type: 'regression' 'classification'. predict Logical. Produce map (TRUE, default) fit validate model (FALSE). predType Character. Type final output raster. Either \"raw\" class predictions \"prob\" class probabilities. Class probabilities available classification models (predict.train). filename Path output file (optional). NULL, standard raster handling apply, .e. storage either memory raster temp directory. verbose Logical. prints progress statistics execution overwrite logical. Overwrite spatial prediction raster already exists. ... arguments passed train","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Supervised Classification — superClass","text":"superClass object (effectively list) containing: $model: fitted model $modelFit: model fit statistics $training: indexes samples used training $validation: list $performance: performance estimates based independent validation (confusion matrix etc.) $validationSamples: actual pixel coordinates plus reference predicted values used validation $validationGeometry: validation polygpns (clipped mindist training geometries) $map: predicted raster $classMapping: data.frame containing integer <-> label mapping","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Supervised Classification — superClass","text":"Note superClass automatically loads lattice randomForest package. SuperClass performs following steps: Ensure non-overlap training validation data. neccesary avoid biased performance estimates. minimum distance (minDist) pixels can provided enforce given distance training validation data. Sample training coordinates. trainData (valData present) polygons superClass calculate area per polygon sample nSamples locations per class within polygons. number samples per individual polygon scales polygon area, .e. bigger polygon, samples. Split training/validation valData provided (reccomended) samples polygons held-used model fitting validation. trainPartition provided trainingPolygons divided training polygons validation polygons. Extract raster data predictor values sample pixels extracted img Fit model. Using caret::train sampled training data model fit, including parameter tuning (tuneLength) kfold cross-validation. polygonBasedCV=TRUE define cross-validation folds based polygons (reccomended) otherwise performed per-pixel basis. Predict classes pixels img based final model. Validate model independent validation data.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Supervised Classification — superClass","text":"","code":"library(RStoolbox) library(caret) library(randomForest) #> randomForest 4.7-1.2 #> Type rfNews() to see new features/changes/bug fixes. #> #> Attaching package: ‘randomForest’ #> The following object is masked from ‘package:gridExtra’: #> #> combine #> The following object is masked from ‘package:ggplot2’: #> #> margin library(e1071) #> #> Attaching package: ‘e1071’ #> The following object is masked from ‘package:terra’: #> #> interpolate library(terra) train <- readRDS(system.file(\"external/trainingPoints_rlogo.rds\", package=\"RStoolbox\")) ## Plot training data olpar <- par(no.readonly = TRUE) # back-up par par(mfrow=c(1,2)) colors <- c(\"yellow\", \"green\", \"deeppink\") plotRGB(rlogo) plot(train, add = TRUE, col = colors[train$class], pch = 19) ## Fit classifier (splitting training into 70\\% training data, 30\\% validation data) SC <- superClass(rlogo, trainData = train, responseCol = \"class\", model = \"rf\", tuneLength = 1, trainPartition = 0.7) #> 15:22:30 | Begin sampling training data #> 15:22:30 | Starting to fit model #> 15:22:31 | Starting spatial predict #> 15:22:31 | Begin validation #> ******************** Model summary ******************** #> Random Forest #> #> 21 samples #> 3 predictor #> 3 classes: 'A', 'B', 'C' #> #> No pre-processing #> Resampling: Cross-Validated (5 fold) #> Summary of sample sizes: 16, 16, 18, 17, 17 #> Resampling results: #> #> Accuracy Kappa #> 1 1 #> #> Tuning parameter 'mtry' was held constant at a value of 1 #> [[1]] #> TrainAccuracy TrainKappa method #> 1 1 1 rf #> #> [[2]] #> Cross-Validated (5 fold) Confusion Matrix #> #> (entries are average cell counts across resamples) #> #> Reference #> Prediction A B C #> A 1.4 0.0 0.0 #> B 0.0 1.4 0.0 #> C 0.0 0.0 1.4 #> #> Accuracy (average) : 1 #> #> #> ******************** Validation summary ******************** #> Confusion Matrix and Statistics #> #> Reference #> Prediction A B C #> A 3 0 0 #> B 0 3 0 #> C 0 0 3 #> #> Overall Statistics #> #> Accuracy : 1 #> 95% CI : (0.6637, 1) #> No Information Rate : 0.3333 #> P-Value [Acc > NIR] : 5.081e-05 #> #> Kappa : 1 #> #> Mcnemar's Test P-Value : NA #> #> Statistics by Class: #> #> Class: A Class: B Class: C #> Sensitivity 1.0000 1.0000 1.0000 #> Specificity 1.0000 1.0000 1.0000 #> Pos Pred Value 1.0000 1.0000 1.0000 #> Neg Pred Value 1.0000 1.0000 1.0000 #> Prevalence 0.3333 0.3333 0.3333 #> Detection Rate 0.3333 0.3333 0.3333 #> Detection Prevalence 0.3333 0.3333 0.3333 #> Balanced Accuracy 1.0000 1.0000 1.0000 SC #> superClass results #> ************ Validation ************** #> $validation #> Confusion Matrix and Statistics #> #> Reference #> Prediction A B C #> A 3 0 0 #> B 0 3 0 #> C 0 0 3 #> #> Overall Statistics #> #> Accuracy : 1 #> 95% CI : (0.6637, 1) #> No Information Rate : 0.3333 #> P-Value [Acc > NIR] : 5.081e-05 #> #> Kappa : 1 #> #> Mcnemar's Test P-Value : NA #> #> Statistics by Class: #> #> Class: A Class: B Class: C #> Sensitivity 1.0000 1.0000 1.0000 #> Specificity 1.0000 1.0000 1.0000 #> Pos Pred Value 1.0000 1.0000 1.0000 #> Neg Pred Value 1.0000 1.0000 1.0000 #> Prevalence 0.3333 0.3333 0.3333 #> Detection Rate 0.3333 0.3333 0.3333 #> Detection Prevalence 0.3333 0.3333 0.3333 #> Balanced Accuracy 1.0000 1.0000 1.0000 #> #> *************** Map ****************** #> $map #> class : SpatRaster #> dimensions : 77, 101, 1 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> name : class_supervised #> min value : 1 #> max value : 3 ## Plots plot(SC$map, col = colors, legend = FALSE, axes = FALSE, box = FALSE) legend(1,1, legend = levels(train$class), fill = colors , title = \"Classes\", horiz = TRUE, bty = \"n\") par(olpar) # reset par"},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":null,"dir":"Reference","previous_headings":"","what":"Tasseled Cap Transformation — tasseledCap","title":"Tasseled Cap Transformation — tasseledCap","text":"Calculates brightness, greenness wetness multispectral imagery. Currently implemented Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5 RapidEye.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tasseled Cap Transformation — tasseledCap","text":"","code":"tasseledCap(img, sat, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tasseled Cap Transformation — tasseledCap","text":"img SpatRaster. Input image. Band order must correspond sensor specifications (see Details Examples) sat Character. Sensor; one : c(\"Landsat4TM\", \"Landsat5TM\", \"Landsat7ETM\", \"Landsat8OLI\", \"MODIS\", \"QuickBird\", \"Spot5\", \"RapidEye\"). Case irrelevant. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tasseled Cap Transformation — tasseledCap","text":"Returns SpatRaster thee bands: brigthness, greenness, (soil) wetness.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tasseled Cap Transformation — tasseledCap","text":"Currently implemented: Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5, RapdiEye. Input data must top atmosphere reflectance. Moreover, bands must provided ascending order listed table . Irrelevant bands, Landsat Thermal Bands QuickBird/Spot5 Panchromatic Bands must omitted. Required bands :","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Tasseled Cap Transformation — tasseledCap","text":"Crist (1985) \"TM Tasseled Cap Equivalent Transformation Reflectance Factor Data.\" Remote Sensing Environment 17 (3): 301-306 Huang et al. (2002) \"Derivation Tasselled Cap Transformation Based Landsat 7 -Satellite Reflectance.\" International Journal Remote Sensing 23 (8): 1741-1748 Baig et al. (2014) \"Derivation Tasselled Cap Transformation Based Landsat 8 -Satellite Reflectance.\" Remote Sensing Letters 5 (5): 423-431. Lobser et al. (2007) \"MODIS Tasselled Cap: Land Cover Characteristics Expressed Transformed MODIS Data.\" International Journal Remote Sensing 28 (22): 5079-5101. Yarbrough et al. (2005) \"QuickBird 2 tasseled cap transform coefficients: comparison derivation methods.\" Pecora 16 Global Priorities Land Remote Sensing: 23-27. Ivits et al. (2008) \"Orthogonal transformation segmented SPOT5 images.\" Photogrammetric Engineering & Remote Sensing 74 (11): 1351-1364. Schoenert et al. (2014) \"Derivation tasseled cap coefficients RapidEye data.\" Earth Resources Environmental Remote Sensing/GIS Applications V (9245): 92450Qs.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tasseled Cap Transformation — tasseledCap","text":"","code":"library(terra) ## Run tasseled cap (exclude thermal band 6) lsat_tc <- tasseledCap(lsat[[c(1:5,7)]], sat = \"Landsat5TM\") lsat_tc #> class : SpatRaster #> dimensions : 310, 287, 3 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : brightness, greenness, wetness #> min values : 33.0776, -21.2454, 10.9682 #> max values : 254.0931, 69.6422, 122.4285 plot(lsat_tc)"},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":null,"dir":"Reference","previous_headings":"","what":"Topographic Illumination Correction — topCor","title":"Topographic Illumination Correction — topCor","text":"account correct changes illumination due terrain elevation.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Topographic Illumination Correction — topCor","text":"","code":"topCor( img, dem, metaData, solarAngles = c(), method = \"C\", stratImg = NULL, nStrat = 5, illu, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Topographic Illumination Correction — topCor","text":"img SpatRaster. Imagery correct dem SpatRaster. Either digital elevation model RasterLayer RasterStack/Brick pre-calculated slope aspect (see terrain) case layers must named 'slope' 'aspect'. Must dimensions img. metaData Character, ImageMetaData. Either path Landsat meta-data file (MTL) ImageMetaData object (see readMeta) solarAngles Numeric vector containing sun azimuth sun zenith (radians order). needed metaData provided method Character. One c(\"cos\", \"avgcos\", \"minnaert\", \"C\", \"stat\", \"illu\"). Choosing 'illu' return local illumination map. stratImg RasterLayer SpatRaster define strata, e.g. NDVI. string 'slope' case stratification nStrat slope classes. relevant method = 'minnaert'. nStrat Integer. Number bins quantiles stratify . bin less 50 samples merged next bin. relevant method = 'minnaert'. illu SpatRaster. Optional pre-calculated ilumination map. Run topCor method=\"illu\" calculate ilumination map ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Topographic Illumination Correction — topCor","text":"SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Topographic Illumination Correction — topCor","text":"detailed discussion various approaches please see Riano et al. (2003). minnaert correction can stratified different landcover characteristics. stratImg = 'slope' analysis stratified slope, .e. slope values divided nStrat classes correction coefficient k calculated applied separately slope class. alternative stratify vegetation index case additional raster layer provided via stratImg argument.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Topographic Illumination Correction — topCor","text":"Riano et al. (2003) Assessment different topographic correction Landsat-TM data mapping vegetation types. IEEE Transactions Geoscience Remote Sensing.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Topographic Illumination Correction — topCor","text":"","code":"## Load example data metaData <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(metaData) ## Minnaert correction, solar angles from metaData lsat_minnaert <- topCor(lsat, dem = srtm, metaData = metaData, method = \"minnaert\") #> 15:22:32 | Calculate slope and aspect #> 15:22:32 | Calculate illumination map #> 15:22:32 | Correct imagery #> 15:22:32 | Estimate coefficients ## C correction, solar angles provided manually lsat_C <- topCor(lsat, dem = srtm, solarAngles = c(1.081533, 0.7023922), method = \"C\") #> 15:22:32 | Calculate slope and aspect #> 15:22:32 | Calculate illumination map #> 15:22:32 | Correct imagery #> 15:22:33 | Estimate coefficients"},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Unsupervised Classification — unsuperClass","title":"Unsupervised Classification — unsuperClass","text":"Unsupervised clustering SpatRaster data using kmeans clustering","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unsupervised Classification — unsuperClass","text":"","code":"unsuperClass( img, nSamples = 10000, nClasses = 5, nStarts = 25, nIter = 100, norm = FALSE, clusterMap = TRUE, algorithm = \"Hartigan-Wong\", output = \"classes\", ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unsupervised Classification — unsuperClass","text":"img SpatRaster. nSamples Integer. Number random samples draw fit cluster map. relevant clusterMap = TRUE. nClasses Integer. Number classes. nStarts Integer. Number random starts kmeans algorithm. nIter Integer. Maximal number iterations allowed. norm Logical. TRUE normalize img first using normImage. Normalizing beneficial predictors different scales. clusterMap Logical. Fit kmeans model random subset img (see Details). algorithm Character. kmeans algorithm. One c(\"Hartigan-Wong\", \"Lloyd\", \"MacQueen\") output Character. Either 'classes' (kmeans class; default) 'distances' (euclidean distance cluster center). ... arguments passed writeRaster, e.g. filename","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Unsupervised Classification — unsuperClass","text":"Returns RStoolbox::unsuperClass object, list containing kmeans model ($model) raster map ($map). output = \"classes\", $map contains SpatRaster discrete classes (kmeans clusters); output = \"distances\" $map contains SpatRaster, `nClasses` layers, layer maps euclidean distance corresponding class centroid.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Unsupervised Classification — unsuperClass","text":"Clustering done using kmeans. can done pixels image (clusterMap=FALSE), however can slow memory safe. Therefore large raster data (> memory), typically case remote sensing imagery advisable choose clusterMap=TRUE (default). means kmeans cluster model calculated based random subset pixels (nSamples). distance ** pixels cluster centers calculated stepwise fashion using predict. Class assignment based minimum euclidean distance cluster centers. solution kmeans algorithm often depends initial configuration class centers chosen randomly. Therefore, kmeans usually run multiple random starting configurations order find convergent solution different starting configurations. nStarts argument allows specify many random starts conducted.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Unsupervised Classification — unsuperClass","text":"","code":"if (FALSE) { # \\dontrun{ library(terra) input <- rlogo ## Plot olpar <- par(no.readonly = TRUE) # back-up par par(mfrow=c(1,2)) plotRGB(input) ## Run classification set.seed(25) unC <- unsuperClass(input, nSamples = 100, nClasses = 5, nStarts = 5) unC ## Plots colors <- rainbow(5) plot(unC$map, col = colors, legend = FALSE, axes = FALSE, box = FALSE) legend(1,1, legend = paste0(\"C\",1:5), fill = colors, title = \"Classes\", horiz = TRUE, bty = \"n\") ## Return the distance of each pixel to each class centroid unC <- unsuperClass(input, nSamples = 100, nClasses = 3, output = \"distances\") unC ggR(unC$map, 1:3, geom_raster = TRUE) par(olpar) # reset par } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":null,"dir":"Reference","previous_headings":"","what":"Map accuracy assessment — validateMap","title":"Map accuracy assessment — validateMap","text":"validate map classification regression model. can useful update accuracy assessment filtering, e.g. minimum mapping unit.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Map accuracy assessment — validateMap","text":"","code":"validateMap( map, valData, responseCol, nSamplesV = 500, mode = \"classification\", classMapping = NULL )"},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Map accuracy assessment — validateMap","text":"map SpatRaster. classified map. valData sf object validation data (POLYGONs POINTs). responseCol Character. Column containing validation data attribute table valData. nSamplesV Integer. Number pixels sample validation (applies polygons). mode Character. Either 'classification' 'regression'. classMapping optional data.frame columns 'class' 'classID' defining mapping raster integers class names.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Map accuracy assessment — validateMap","text":"Returns structured list includng preformance confusion-matrix validated input data","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Map accuracy assessment — validateMap","text":"","code":"library(caret) library(terra) ## Training data poly <- readRDS(system.file(\"external/trainingPolygons_lsat.rds\", package=\"RStoolbox\")) ## Split training data in training and validation set (50%-50%) splitIn <- createDataPartition(poly$class, p = .5)[[1]] train <- poly[splitIn,] val <- poly[-splitIn,] ## Classify (deliberately poorly) sc <- superClass(lsat, trainData = train, responseCol = \"class\", nSamples = 50, model = \"mlc\") #> 15:22:33 | Begin sampling training data #> 15:22:33 | Starting to fit model #> 15:22:33 | Starting spatial predict #> ******************** Model summary ******************** #> Maximum Likelihood Classification #> #> 274 samples #> 7 predictor #> 4 classes: 'cleared', 'fallen_dry', 'forest', 'water' #> #> No pre-processing #> Resampling: Cross-Validated (5 fold) #> Summary of sample sizes: 219, 219, 219, 220, 219 #> Resampling results: #> #> Accuracy Kappa #> 1 1 #> #> [[1]] #> TrainAccuracy TrainKappa method #> 1 1 1 custom #> #> [[2]] #> Cross-Validated (5 fold) Confusion Matrix #> #> (entries are average cell counts across resamples) #> #> Reference #> Prediction cleared fallen_dry forest water #> cleared 16.0 0.0 0.0 0.0 #> fallen_dry 0.0 6.8 0.0 0.0 #> forest 0.0 0.0 16.0 0.0 #> water 0.0 0.0 0.0 16.0 #> #> Accuracy (average) : 1 #> #> #> ******************** Validation summary ******************** #> [1] \"No independent validation was performed!\" ## Polish map with majority filter polishedMap <- focal(sc$map, matrix(1,3,3), fun = modal) ## Validation ## Before filtering val0 <- validateMap(sc$map, valData = val, responseCol = \"class\", classMapping = sc$classMapping) ## After filtering val1 <- validateMap(polishedMap, valData = val, responseCol = \"class\", classMapping = sc$classMapping)"},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":null,"dir":"Reference","previous_headings":"","what":"Write ENVI spectral libraries — writeSLI","title":"Write ENVI spectral libraries — writeSLI","text":"Writes binary ENVI spectral library files (sli) accompanying header (.sli.hdr) files ASCII spectral library files ENVI format.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write ENVI spectral libraries — writeSLI","text":"","code":"writeSLI( x, path, wavl.units = \"Micrometers\", scaleF = 1, mode = \"bin\", endian = .Platform$endian )"},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write ENVI spectral libraries — writeSLI","text":"x data.frame first column containing wavelengths columns containing spectra. path path spectral library file created. wavl.units wavelength units. Defaults Micrometers. Nanometers another typical option. scaleF optional reflectance scaling factor. Defaults 1. mode character string specifying output file type. Must one \"bin\" binary .sli files \"ASCII\" ASCII ENVI plot files. endian character. Optional. default endian determined based platform, can forced manually setting either \"little\" \"big\".","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write ENVI spectral libraries — writeSLI","text":"return anything, write SLI file directly drive specified path parameter","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Write ENVI spectral libraries — writeSLI","text":"ENVI spectral libraries ending .sli binary arrays spectra saved rows.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write ENVI spectral libraries — writeSLI","text":"","code":"## Example data sliFile <- system.file(\"external/vegSpec.sli\", package=\"RStoolbox\") sliTmpFile <- paste0(tempdir(),\"/vegetationSpectra.sli\") ## Read spectral library sli <- readSLI(sliFile) head(sli) #> wavelength veg_stressed veg_vital #> 1 350 0.008958003 0.008836994 #> 2 351 0.008910760 0.008909440 #> 3 352 0.008874181 0.008972186 #> 4 353 0.008847097 0.009025744 #> 5 354 0.008829174 0.009071405 #> 6 355 0.008819440 0.009109739 plot(sli[,1:2], col = \"orange\", type = \"l\") lines(sli[,c(1,3)], col = \"green\") ## Write to binary spectral library writeSLI(sli, path = sliTmpFile)"},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-100","dir":"Changelog","previous_headings":"","what":"RStoolbox 1.0.0","title":"RStoolbox 1.0.0","text":"CRAN release: 2024-04-25 Updating MESMA, minor changes major release","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-1-0-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 1.0.0","text":"mesma() now better differentiates SMA MESMA: single endmember unmixing, supplied endmember represents class unmix (row row). multiple endmemeber unmixing, column class can used group endmembers class. multiple endmembers per class provided, mesma() compute number SMA (determined new argument n_models) multiple endmember combinations drawn endmembers select best fit per pixel based lowest RMSE. See ?mesma details (fixes #57, reported @ytarazona)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-1-0-0","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 1.0.0","text":"mesma() now implements sum one constraint default (argument sum_to_one) (fixes #62, reported @michaeldorman) added new example mesma() reflect changes","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-040","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.4.0","title":"RStoolbox 0.4.0","text":"CRAN release: 2024-01-17 Rewrite RStoolbox, migration raster terra sp sf","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-4-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.4.0","text":"RStoolbox moved outdated sp raster packages sf terra ensure long term support tools. Thrown unnecessary libraries","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-4-0","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.4.0","text":"rasterPCA(): Fixed bug caused method unit tests fail Linux due corrupted covariance matrix calculated previously terra::layerCor() superClass() unable predict NA raster data (closes #102, reported @bappa10085)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-030","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.3.0","title":"RStoolbox 0.3.0","text":"CRAN release: 2022-03-07","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-3-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.3.0","text":"rasterCVA() default longer enforces minimal change magnitude (can still accomplished tmf argument). Also new argument nct allows fix threshold user selected value instead deriving based median observed change magnitudes. unsuperClass() new argument output allows return distances cluster centers raster layers, instead class added spectral index kNDVI spectralIndices() suggested Camps-Valls et al (2021) added support terra::SpatRast objects throughout RStoolbox (alternative raster objects). Note: internal functionality still based raster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-3-0","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.3.0","text":"arguments master slave coregisterImages() deprecated favor ref img, respectively (closes #63, suggested @MatthiasSiewert)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-3-0","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.3.0","text":"rasterCVA() estimates median values now entire rasters per chunk cloudMask() now returns NA non-clouds instead NaN topCor() now works tiny rasters well (fixes #55, reported @latenooker) rasterPCA() now correctly considers number observations face missing values (fixes #79, reported @andliszmmu) superClass() now accepts different geometries trainData valData (fixes #73, suggested @Silviculturalist) fix readMeta() MTL files delivered Landsat collection data (fixes #71, reported @jkoellin et al.)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-026","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.6","title":"RStoolbox 0.2.6","text":"CRAN release: 2019-07-23","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-6","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.6","text":"red-edge inflection point (REIP), normalized difference red-edge indices (NDREI1, NDREI2), green-band chlorophyll index (CLG), red-edge chlorophyll index (CLRE) Modified Chlorophyll Absorption Ratio Index (MCARI) MERIS Terrestrial Chlorophyll Index (MTCI)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-6","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.6","text":"readSLI() writeSLI() now handle endian binary spectral libraries correctly (#47, fix contributed @aloboa) fix calculation prediction probabilities superClass()(reported Benson Kemboi) adapt raster 2.9.5 API changes fix order thermal calibration coefficients Landsat 8 L1 MTL metadata readMeta (reported Xiaoma Li) fixed issue readSLI() find header files dots pathnames (#51, reported @aloboa)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-6","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.6","text":"modified readSLI label parsing. Internal white space now converted underscores (#52)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-024","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.4","title":"RStoolbox 0.2.4","text":"CRAN release: 2019-01-08","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-4","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.4","text":"function oneHotEncode(): splits single rasterLayer multiple layers (one per class) one-hot encoding, .e. pixel value = 1 matches, pixel value = 0 classes (background). ggR() can now display one layer. layer can plotted subplot multi-panel figure. encodeQA(), decodeQA() classifyQA() can now deal new QA format introduced Landsat Collection data. Legacy QA designations can still interpreted setting legacy argument. new predict() method unsupervised classification models (unsuperClass()).","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-4","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.4","text":"radCor() DOS methods now work Landsat 8 OLI","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-4","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.4","text":"fix unsuperClass() algorithms Hartigan-Wong (reported Alex Ilich)","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-2","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.2","text":"added tasseledCap() coefficients Quickbird, Spot5 RapidEye","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-2","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.2","text":"readEE() ‘Date’ column now returned POSIXct instead POSIXlt","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-2","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.2","text":"corrected tasseledCap() coefficient Landsat 5 TM (#40, reported @philipperufin)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-021","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.1","title":"RStoolbox 0.2.1","text":"CRAN release: 2018-04-09","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-1","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.1","text":"fixed non-portable c++ headers","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-020","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.0","title":"RStoolbox 0.2.0","text":"CRAN release: 2018-04-05","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.0","text":"function mesma() spectral unmixing (#33, provided Jakob Schwalb-Willmann)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.0","text":"improved NA handling faster implementation mlc classifier (#32, pull request Neal Fultz) adapt upcoming caret version (new constraint caret >= 6.0-79)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-0110","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.10","title":"RStoolbox 0.1.10","text":"CRAN release: 2017-11-10","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-10","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.10","text":"fix tests upcoming raster version","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-019","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.9","title":"RStoolbox 0.1.9","text":"CRAN release: 2017-08-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-9","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.9","text":"adapt new caret version fix readEE() new EarthExplorer formats corrected sign greenness tasseledCap() coefficient Landsat5 TM band 1 (reported Thomas Day) adapt readMeta() stackMeta() new Landsat collection 1 metadata","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-018","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.8","title":"RStoolbox 0.1.8","text":"CRAN release: 2017-04-15","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-8","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.8","text":"spectralIndices() can now apply mask internally, e.g. exclude cloud pixels. New arguments : maskLayer maskValue (suggested Andrea Hess). added spectral index GNDWI","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-8","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.8","text":"update readEE() deal new EarthExplorer export columns (reported Christian Bauer)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-017","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.7","title":"RStoolbox 0.1.7","text":"CRAN release: 2017-01-10","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-7","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.7","text":"spectralIndices() new argument skipRefCheck, skips heuristic check reflectance-like values [0,1] run EVI/EVI2 requested. can usefull clouds reflectance > 1.5 part image. superClass() now returns geometries used validation, e.g. polygons (validationvalidationgeometry) also exact samples taken validation including cell number coordinates (validationvalidationvalidationSamples) added example data-set spectral library see ?readSLI increased overall test coverage","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-7","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.7","text":"ESUN lookup tables radCor() adjusted match current USGS recommendations : https://landsat.usgs.gov/esun spectralIndices() swir wavelength ranges now defined consistently correctly. Bands formerly provided swir1 (version <1.7.0) now (>=1.7.0) provided swir2 former swir2 swir3 respectively (see docu). actual calculations correct, naming .","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-7","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.7","text":"fix ggR() ggRGB() annotation mode (default). image drawn excessive memory allocation requested (= RStudio crash) (reported Christian Walther) fix spectralIndices() documentation NDWI. Formula based McFeeters1996 attributed Gao1996. Now NDWI (McFeeters) NDWI2 (Gao) (reported Christian Bauer) estimateHaze() now ensures correct histogram order, raster read disk (reported Xavier Bailleau). readMeta() now makes concise bandnames also Landsat Collection MTL files. fix radCor() Landsat 4 TM (reported Thomas Day) classifyQA() confidence layer type=‘water’ now correctly returns confidence levels [1,3] enable reading ENVI plot files ASCII mode readSLI() Deprecated: * spectralIndices() index LSWI deprecated, identical now available NDWI2.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-016","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.6","title":"RStoolbox 0.1.6","text":"CRAN release: 2016-11-07","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-6","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.6","text":"fix import issue: replace deprecated export caret","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-015","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.5","title":"RStoolbox 0.1.5","text":"CRAN release: 2016-10-06","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-5","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.5","text":"bandSet argument radCor() used process subset bands longer return unprocessed bands along processed bands. Instead processed bands returned. default superClass() now use dataType = ‘INT2S’ classification maps avoid issues raster NA handling INT1U Allow reading importing Landsat MSS MTL files readMeta() stackMeta() (@aszeitz, #7)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-5","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.5","text":"fix readMeta time-stamp conversion now correctly set GMT time (@mraraju, #12) radCor caused R crash bandSet single band fix single RasterLayer capability superClass spectralIndices now calculates documented indices specified (@mej1d1, #6) unsuperClass predicted map now handles NAs properly pifMatch return adjusted image (@tmb3006, #13) Deprecated: * argument norm dropped rasterPCA, effectively duplicate standardized pca (spca) argument function.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-014","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.4","title":"RStoolbox 0.1.4","text":"CRAN release: 2016-01-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-4","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.4","text":"new function validateMap() assessing map accuracy separately model fitting, e.g. majority MMU filtering new function getValidation() extract specific validation results superClass objects (proposed James Duffy) new spectral index NDVIc (proposed Jeff Evans) new argument scaleFactor spectralIndices() calculation EVI/EVI2 based scaled reflectance values. implemented dark object subtraction radCor(..,method=‘sdos’) Landsat 8 data (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-4","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.4","text":"superClass based polygons now considers pixels center coordinate within polygon rasterCVA now returns angles 0 360° instead 0:45 quadrant (reported Martin Wegmann) improved dark object DN estimation based maximum slope histogram estimateHaze() (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-4","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.4","text":"superClass failed neither valData trainPartition specified. regression introduced 0.1.3 (reported Anna Stephani) spectralIndices valid value range EVI/EVI2 now [-1,1] radCor returned smallest integer instead NA NA pixels fix ‘sdos’ non-contiguous bands radCor (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-013","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.3","title":"RStoolbox 0.1.3","text":"CRAN release: 2015-11-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-3","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.3","text":"new logical argument predict() superClass. Disables prediction full raster (validation still conducted). new generic predict() function superClass objects. Useful separate model training prediction. new example data set (landcover training polygons) lsat example data /extdata/trainingPolygons.rds","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-3","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.3","text":"fix histMatch single layers (affected also ‘ihs’ pan-sharpening) fix superClass validation sampling factors (character based factors lead wrong factor conversions wrong validation results) improved handling training polygons overlaps shared borders superClass improved checks error messages insufficient training polygons","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-012","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.2","title":"RStoolbox 0.1.2","text":"CRAN release: 2015-11-04","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-2","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.2","text":"New model superClass: maximum likelihood classification (model = “mlc”)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-2","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.2","text":"Restrict calculation EVI/EVI2 reflectance data (#3) Enforce valid value ranges radCor(): radiance: [0,+Inf], reflectance: [0,1]. Includes new argument clamp turn (default).","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-011","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.1","title":"RStoolbox 0.1.1","text":"CRAN release: 2015-09-08 Added kernlab suggested packages able test examples","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-010","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.0","title":"RStoolbox 0.1.0","text":"CRAN release: 2015-09-05 Initial release CRAN (2015-09-05) following functions: * classifyQA() * cloudMask() * cloudShadowMask() * coregisterImages() * decodeQA() * encodeQA() * estimateHaze() * fortify.raster() * fCover() * getMeta() * ggR() * ggRGB() * histMatch() * ImageMetaData() * normImage() * panSharpen() * pifMatch() * radCor() * rasterCVA() * rasterEntropy() * rasterPCA() * readEE() * readMeta() * readRSTBX() * readSLI() * rescaleImage() * rsOpts() * sam() * saveRSTBX() * spectralIndices() * stackMeta() * superClass() * tasseledCap() * topCor() * unsuperClass() * writeSLI() Included example data sets: * data(srtm) * data(lsat) * data(rlogo)","code":""}]
+[{"path":"https://bleutner.github.io/RStoolbox/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Benjamin Leutner. Author. Ned Horning. Author. Jakob Schwalb-Willmann. Author. Robert J. Hijmans. Contributor. Konstantin Mueller. Author, maintainer.","code":""},{"path":"https://bleutner.github.io/RStoolbox/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Leutner B, Horning N, Schwalb-Willmann J, Mueller K (2024). RStoolbox: Remote Sensing Data Analysis. R package version 1.0.1, https://github.com/bleutner/RStoolbox, https://bleutner.github.io/RStoolbox/.","code":"@Manual{, title = {RStoolbox: Remote Sensing Data Analysis}, author = {Benjamin Leutner and Ned Horning and Jakob Schwalb-Willmann and Konstantin Mueller}, year = {2024}, note = {R package version 1.0.1, https://github.com/bleutner/RStoolbox}, url = {https://bleutner.github.io/RStoolbox/}, }"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"rstoolbox-","dir":"","previous_headings":"","what":"Remote Sensing Data Analysis","title":"Remote Sensing Data Analysis","text":"RStoolbox R package providing wide range tools every-day remote sensing processing needs. available tool-set covers many aspects data import, pre-processing, data analysis, image classification graphical display. RStoolbox builds upon terra package, makes suitable processing large data-sets even smaller workstations. Find RStoolbox webpage.","code":""},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Remote Sensing Data Analysis","text":"package available CRAN can installed usual via install latest version GitHub need r-base-dev (Linux) Rtools (Windows) installed. run following lines:","code":"install.packages(\"RStoolbox\") library(devtools) install_github(\"bleutner/RStoolbox\")"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"get-started","dir":"","previous_headings":"","what":"Get started","title":"Remote Sensing Data Analysis","text":"RStoolbox implements variety remote sensing methods workflows. examples get started. examples can found documentation respective functions.","code":""},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-1-classifications","dir":"","previous_headings":"Get started","what":"Example 1: Classifications","title":"Remote Sensing Data Analysis","text":"example shows unsupervised classification workflow based kmeans clustering: training data available, e.g. labeled polygons, RStoolbox can used conduct supervised classification. workflow employs randomForest train classification model: Created 2024-04-19 reprex v2.1.0","code":"library(RStoolbox) # unsupervised classification with 3 classes uc <- unsuperClass(lsat, nClasses = 3) # plot result using ggplot ggR(uc$map, geom_raster = T, forceCat = T) + scale_fill_manual(values = c(\"darkgreen\", \"blue\", \"sandybrown\")) 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\") + geom_sf(data = train, aes(fill = class)) + scale_fill_manual(values = c(\"yellow\", \"sandybrown\", \"darkgreen\", \"blue\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # 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, class_supervised = levels(train$class)) ggR(r, geom_raster = T, forceCat = T) + scale_fill_manual(values = c(\"yellow\", \"sandybrown\", \"darkgreen\", \"blue\"))"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-2-spectral-unmixing","dir":"","previous_headings":"Get started","what":"Example 2: Spectral Unmixing","title":"Remote Sensing Data Analysis","text":"RStoolbox offers spectral unmixing implementing Multiple Endmember Spectral Mixture Analysis (MESMA) approach estimating fractions spectral classes, spectra surfaces materials, sub-pixel scale. following workflow shows simple Spectral Mixture Analysis (SMA) single endmembers per class, extracted lsat example image cell id: Instead, one can define multiple endmembers per class conduct Multiple Endmember Spectral Mixture Analysis (MESMA):","code":"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) 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) # 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)"},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-3-cloud-masking","dir":"","previous_headings":"Get started","what":"Example 3: Cloud Masking","title":"Remote Sensing Data Analysis","text":"RStoolbox comes suite pre-processing functions, including cloudMask identify clouds optical satellite imagery:","code":"library(ggplot2) # lsat example scene, with two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") # calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) # 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(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/index.html","id":"example-4-radiometric-and-atmospheric-correction","dir":"","previous_headings":"Get started","what":"Example 4: Radiometric and atmospheric correction","title":"Remote Sensing Data Analysis","text":"radCor, users can compute radiometric simple atmospheric corrections (based dark object substraction): Created 2024-04-19 reprex v2.1.0","code":"library(terra) # import Landsat meta data mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) # convert DN to top of atmosphere reflectance and brightness temperature lsat_ref <- radCor(lsat_t, metaData = metaData, method = \"apref\") # correct DN to at-surface-reflecatance with DOS (Chavez decay model) lsat_sref <- radCor(lsat_t, metaData = metaData) # correct DN to at-surface-reflecatance with simple DOS and automatic haze estimation hazeDN <- estimateHaze(lsat_t, hazeBands = 1:4, darkProp = 0.01, plot = FALSE) lsat_sref <- 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\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":null,"dir":"Reference","previous_headings":"","what":"ImageMetaData Class — ImageMetaData","title":"ImageMetaData Class — ImageMetaData","text":"ImageMetaData Class","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ImageMetaData Class — ImageMetaData","text":"","code":"ImageMetaData( file = NA, format = NA, sat = NA, sen = NA, scene = NA, colNum = NA, colTier = NA, proj = NA, date = NA, pdate = NA, path = NA, row = NA, az = NA, selv = NA, esd = NA, files = NA, bands = NA, quant = NA, cat = NA, na = NA, vsat = NA, scal = NA, dtyp = NA, calrad = NA, calref = NA, calbt = NA, radRes = NA, spatRes = NA )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ImageMetaData Class — ImageMetaData","text":"file Character. Metadata file format Character. Metadata format, e.g. xml, mtl sat Character. Satellite platform sen Character. Sensor scene Character. Scene_ID colNum Character Collection number colTier Character Collection tier proj CRS. Projection. date POSIXct. Aquisition date. pdate POSIXct. Processing date. path Integer. Path. row Integer. Row. az Numeric. Sun azimuth selv Numeric. Sun elevation esd Numeric. Earth-sun distance files Character vector. Files containing data, e.g. tiff files bands Character vector. Band names quant Character vector. Quantity, one c(\"dn\", \"tra\", \"tre\", \"sre\", \"bt\", \"idx\", \"angle\") cat Character vector. Category, e.g. c(\"image\", \"pan\", \"index\", \"qa\", \"aux\") na Numeric vector. -data value per band vsat Numeric vector. Saturation value per band scal Numeric vector. Scale factor per band. e.g. data scaled 1000*reflectance integer conversion. dtyp Character vector. Data type per band. calrad data.frame. Calibration coefficients dn->radiance conversion. Must columns 'gain' 'offset'. Rows named according bands. calref data.frame. Calibration coefficients dn->reflectance conversion. Must columns 'gain' 'offset'. Rows named according bands. calbt data.frame. Calibration coefficients dn->brightness temperature conversion. Must columns 'K1' 'K2'. Rows named according bands. radRes Numeric vector. Radiometric resolution per band. spatRes Numeric vector. Spatial resolution per band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"ImageMetaData Class — ImageMetaData","text":"Returns structured, fully customizable meta-data table file","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":null,"dir":"Reference","previous_headings":"","what":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"RStoolbox package provides set functions simplify performing standard remote sensing tasks R.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-import-and-export","dir":"Reference","previous_headings":"","what":"Data Import and Export","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"readMeta: import Landsat metadata MTL XML files stackMeta, getMeta: load Landsat bands based metadata readSLI & writeSLI: read write ENVI spectral libraries saveRSTBX & readRSTBX: save re-import RStoolbox classification objects (model map) readEE: import tidy EarthExplorer search results","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-pre-processing","dir":"Reference","previous_headings":"","what":"Data Pre-Processing","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"radCor: radiometric conversions corrections. Primarily, yet exclusively, intended Landsat data processing. DN radiance reflectance conversion well DOS approaches topCor: topographic illumination correction cloudMask & cloudShadowMask: mask clouds cloud shadows Landsat imagery comes thermal band classifyQA: extract layers Landsat 8 QA bands, e.g. cloud confidence encodeQA & decodeQA: encode/decode Landsat 16-bit QA bands. rescaleImage: rescale image match min/max another image specified min/max range normImage: normalize imagery centering scaling oneHotEncode: one-hot encode raster vector histMatch: matches histograms two scenes pifMatch: matches one scene another based linear regression Pseudo-Invariant Features (PIF) coregisterImages: co-register images based mutual information panSharpen: sharpen coarse resolution image high resolution image (typically panchromatic) estimateHaze: estimate image haze Dark Object Subtraction (DOS)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-analysis","dir":"Reference","previous_headings":"","what":"Data Analysis","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"spectralIndices: calculate set predefined multispectral indices like NDVI tasseledCap: tasseled cap transformation sam: spectral angle mapper rasterPCA: principal components transform raster data rasterCVA: change vector analysis rasterEntropy: calculates shannon entropy unsuperClass: unsupervised classification superClass, validateMap, getValidation: supervised classification validation fCover: fractional cover coarse resolution imagery based high resolution classification mesma: spectral unmixing using Multiple Endmember Spectral Mixture Analysis (MESMA)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/RStoolbox.html","id":"data-display","dir":"Reference","previous_headings":"","what":"Data Display","title":"RStoolbox: A Collection of Remote Sensing Tools — RStoolbox","text":"ggR: single raster layer plotting ggplot2 ggRGB: efficient plotting remote sensing imagery RGB ggplot2","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Classify Landsat QA bands — classifyQA","title":"Classify Landsat QA bands — classifyQA","text":"extracts five classes QA band: background, cloud, cirrus, snow water.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Classify Landsat QA bands — classifyQA","text":"","code":"classifyQA( img, type = c(\"background\", \"cloud\", \"cirrus\", \"snow\", \"water\"), confLayers = FALSE, sensor = \"OLI\", legacy = \"collection1\", ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Classify Landsat QA bands — classifyQA","text":"img SpatRaster. Landsat 8 OLI QA band. type Character. Classes returned. One c(\"background\", \"cloud\", \"cirrus\",\"snow\", \"water\"). confLayers Logical. Return one layer per class classified confidence levels, .e. cloud:low, cloud:med, cloud:high. sensor Sensor encode. Options: c(\"OLI\", \"TIRS\", \"ETM+\", \"TM\", \"MSS\"). legacy Encoding systematic Options: c(\"collection1\", \"pre_collection\"). Default \"collection1\" Landsat Collection 1 8-bit quality designations. Use \"pre_collection\" imagery downloaded Collection 1 quality designations introduced ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Classify Landsat QA bands — classifyQA","text":"Returns SpatRaster maximal five classes: Values outside classes returned NA. confLayers = TRUE RasterStack one layer per condition (except 'background') returned, whereby layer contains confidence level condition.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Classify Landsat QA bands — classifyQA","text":"default class queried *high* confidence. See encodeQA details. return different confidence levels per condition use confLayers=TRUE. approach corresponds way LandsatLook Quality Images produced USGS.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/classifyQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Classify Landsat QA bands — classifyQA","text":"","code":"library(terra) #> terra 1.7.83 qa <- rast(ncol = 100, nrow=100, val = sample(1:2^14, 10000)) ## QA classes qacs <- classifyQA(img = qa) ## Confidence levels qacs_conf <- classifyQA(img = qa, confLayers = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":null,"dir":"Reference","previous_headings":"","what":"Simple Cloud Detection — cloudMask","title":"Simple Cloud Detection — cloudMask","text":"Developed use Landsat data cloudMask relies distinctive difference blue (short-wave band) thermal band semi-automated creation cloud mask. Since relies thermal information work well sensors without thermal bands.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simple Cloud Detection — cloudMask","text":"","code":"cloudMask( x, threshold = 0.2, blue = \"B1_sre\", tir = \"B6_sre\", buffer = NULL, plot = FALSE, verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simple Cloud Detection — cloudMask","text":"x SpatRaster reflectance brightness temperature mask previous run cloudMask returnDiffLayer=TRUE. threshold Numeric. cloud detection threshold. provided guessed. Everything ** threshold considered cloud pixel (unless removed filtering afterwards). blue Character integer. Bandname number blue band tir Character integer. Bandname number thermal band buffer Integer. Number pixels use buffer added identified cloud centers. plot Logical. Plots cloud mask sub-steps (sanitizing etc.) Helpful find proper parametrization. verbose Logical. Print messages suppress.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simple Cloud Detection — cloudMask","text":"Returns SpatRaster two layers: CMASK contains binary cloud mask (1 = cloud, NA = -cloud) NDTCI contains cloud index.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Simple Cloud Detection — cloudMask","text":"Typically clouds cold thermal region high reflectance short wavelengths (blue). calculating normalized difference index two bands thresholding rough cloud mask can obtained. calculating spectral cloud index (call Normalized Difference Thermal Cloud Index (NDTCI)) thermal band matched value range blue band. Therefore, matter whether provide DN, radiance brightness temperature. approach cloud masking simplistic. aims rough removal potentially clouded areas. Nevertheless, able provide satisfactory results. sophisticated approaches, including cloud cast shadow detection can found elsewhere, e.g. fmask. can make sense find suitable threshold cropped version scene. Also make sure make use returnDiffLayer argument save one processing step. Buffering seen final polishing, .e. long pure cloud centers detected properly, might want turn . since takes time calculate. mask detects obvious cloud pixels properly re-enable buffering fine tuning desired. Finally, suitable threshold established re-run cloudMask whole scene threshold go get coffee.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudMask.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simple Cloud Detection — cloudMask","text":"","code":"library(ggplot2) ## Import Landsat example subset ## We have two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") ## Calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) ## Define threshold (re-use the previously calculated index) ## Everything above the threshold is masked ## In addition we apply a region-growing around the core cloud pixels cldmsk_final <- cloudMask(cldmsk, threshold = 0.1, buffer = 5) ## Plot cloudmask ggRGB(lsat, stretch = \"lin\") + ggR(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`). #' ## Estimate cloud shadow displacement ## Interactively (click on cloud pixels and the corresponding shadow pixels) if (FALSE) shadow <- cloudShadowMask(lsat, cldmsk_final, nc = 2) # \\dontrun{} ## Non-interactively. Pre-defined shadow displacement estimate (shiftEstimate) shadow <- cloudShadowMask(lsat, cldmsk_final, shiftEstimate = c(-16,-6)) ## Plot csmask <- terra::merge(cldmsk_final[[1]], shadow) ggRGB(lsat, stretch = \"lin\") + ggR(csmask, ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"blue\", \"yellow\"), labels = c(\"shadow\", \"cloud\"), na.value = NA) #> Warning: Removed 88534 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":null,"dir":"Reference","previous_headings":"","what":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"Intended interactive use, cloudShadowMask ask user select corresponding cloud/cloudShadow pixels used estimate coordinates linear cloudmask shift.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"","code":"cloudShadowMask( img, cm, nc = 5, shiftEstimate = NULL, preciseShift = NULL, quantile = 0.2, returnShift = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"img SpatRaster containing scene cm SpatRaster. Cloud mask (typically result cloudMask) nc Integer. Number control points. points (default) fine final shift estimated coregisterImages. shiftEstimate NULL numeric vector length two (x,y). Estimated displacement shadows map units. NULL, user asked select control points interactively. preciseShift NULL numeric vector length two (x,y). Use cloud/cloud-shadow displacement already known, e.g. previous run cloudShadowMask. quantile Numeric (0 1). Quantile threshold used image co-registration. default 20% quantile total intensity (sum) image used potential shadow mask. returnShift Logical. Return numeric vector containing shift parameters. Useful estimate parameters subset image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"Returns RasterLayer cloud shadow mask (0 = shadow, NA = -shadow).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"simplistic approach cloud shadow masking (simple shift cloud mask). image based accuracy suffer clouds different altitudes. However, just cloudMask quick easy use tool Landsat data just working scenes fMask CDR data hand. Although test scenes perform surprisingly well.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cloud Shadow Masking for Flat Terrain — cloudShadowMask","text":"","code":"library(ggplot2) ## Import Landsat example subset ## We have two tiny clouds in the east ggRGB(lsat, stretch = \"lin\") ## Calculate cloud index cldmsk <- cloudMask(lsat, blue = 1, tir = 6) ggR(cldmsk, 2, geom_raster = TRUE) ## Define threshold (re-use the previously calculated index) ## Everything above the threshold is masked ## In addition we apply a region-growing around the core cloud pixels cldmsk_final <- cloudMask(cldmsk, threshold = 0.1, buffer = 5) ## Plot cloudmask ggRGB(lsat, stretch = \"lin\") + ggR(cldmsk_final[[1]], ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"red\"), na.value = NA) #> Warning: Removed 88752 rows containing missing values or values outside the scale range #> (`geom_raster()`). #' ## Estimate cloud shadow displacement ## Interactively (click on cloud pixels and the corresponding shadow pixels) if (FALSE) shadow <- cloudShadowMask(lsat, cldmsk_final, nc = 2) # \\dontrun{} ## Non-interactively. Pre-defined shadow displacement estimate (shiftEstimate) shadow <- cloudShadowMask(lsat, cldmsk_final, shiftEstimate = c(-16,-6)) ## Plot csmask <- terra::merge(cldmsk_final[[1]], shadow) ggRGB(lsat, stretch = \"lin\") + ggR(csmask, ggLayer = TRUE, forceCat = TRUE, geom_raster = TRUE) + scale_fill_manual(values = c(\"blue\", \"yellow\"), labels = c(\"shadow\", \"cloud\"), na.value = NA) #> Warning: Removed 88534 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":null,"dir":"Reference","previous_headings":"","what":"Image to Image Co-Registration based on Mutual Information — coregisterImages","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"Shifts image match reference image. Matching based maximum mutual information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"","code":"coregisterImages( img, ref, shift = 3, shiftInc = 1, nSamples = 100, reportStats = FALSE, verbose, nBins = 100, master = deprecated(), slave = deprecated(), ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"img SpatRaster. Image shift match reference image. img ref must equal numbers bands. ref SpatRaster. Reference image. img ref must equal numbers bands. shift Numeric matrix. numeric, shift maximal absolute radius (pixels img resolution) img shifted (seq(-shift, shift, =shiftInc)). shift matrix must two columns (x shift y shift), shift values tested. shiftInc Numeric. Shift increment (pixels, restricted integer). Ignored shift matrix. nSamples Integer. Number samples calculate mutual information. reportStats Logical. FALSE return shifted images. Otherwise return shifted image list containing stats mutual information per shift joint histograms. verbose Logical. Print status messages. Overrides global RStoolbox.verbose option. nBins Integer. Number bins calculate joint histogram. master DEPRECATED! Argument renamed. Please use ref now . slave DEPRECATED! Argument renamed. Please use img now . ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"reportStats=FALSE returns SpatRaster (x-y shifted image). reportStats=TRUE returns list containing data.frame mutual information per shift ($MI), shift maximum MI ($bestShift), joint histograms per shift list ($jointHist) shifted image ($coregImg).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"Currently simple linear x - y shift considered tested. higher order shifts (e.g. rotation, non-linear transformation) performed. means imagery already properly geometrically corrected. Mutual information similarity metric originating information theory. Roughly speaking, higher mutual information two data-sets, higher shared information content, .e. similarity. two images exactly co-registered mutual information maximal. trying different image shifts, aim find best overlap maximises mutual information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/coregisterImages.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Image to Image Co-Registration based on Mutual Information — coregisterImages","text":"","code":"library(terra) library(ggplot2) library(reshape2) reference <- rlogo ## Shift reference 2 pixels to the right and 3 up missreg <- shift(reference, 2, 3) ## Compare shift p <- ggR(reference, sat = 1, alpha = .5) p + ggR(missreg, sat = 1, hue = .5, alpha = 0.5, ggLayer=TRUE) ## Coregister images (and report statistics) coreg <- coregisterImages(missreg, ref = reference, nSamples = 500, reportStats = TRUE) ## Plot mutual information per shift ggplot(coreg$MI) + geom_raster(aes(x,y,fill=mi)) ## Plot joint histograms per shift (x/y shift in facet labels) # \\donttest{ df <- melt(coreg$jointHist) df$L1 <- factor(df$L1, levels = names(coreg$jointHist)) df[df$value == 0, \"value\"] <- NA ## don't display p = 0 ggplot(df) + geom_raster(aes(x = Var2, y = Var1,fill=value)) + facet_wrap(~L1) + scale_fill_gradientn(name = \"p\", colours = heat.colors(10), na.value = NA) #> Warning: Removed 443028 rows containing missing values or values outside the scale range #> (`geom_raster()`). # } ## Compare correction ggR(reference, sat = 1, alpha = .5) + ggR(coreg$coregImg, sat = 1, hue = .5, alpha = 0.5, ggLayer=TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Decode QA flags to bit-words — decodeQA","title":"Decode QA flags to bit-words — decodeQA","text":"Intended use Landsat 16-bit QA bands. Decodes pixel quality flags integer bit-words.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decode QA flags to bit-words — decodeQA","text":"","code":"decodeQA(x)"},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decode QA flags to bit-words — decodeQA","text":"x Integer (16bit)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decode QA flags to bit-words — decodeQA","text":"Returns decoded QA values integer","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/decodeQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decode QA flags to bit-words — decodeQA","text":"","code":"decodeQA(53248) #> [1] \"1101000000000000\""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":null,"dir":"Reference","previous_headings":"","what":"Encode QA Conditions to Integers — encodeQA","title":"Encode QA Conditions to Integers — encodeQA","text":"Intended use Landsat 16-bit QA bands. Converts pixel quality flags human readable integer, can used subset QA image. Please aware default settings differ different parameters. Depending , sensor legacy selected, quality parameters used, since sequences available bitwise quality designations differ per sensor collection.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Encode QA Conditions to Integers — encodeQA","text":"","code":"encodeQA( fill = \"no\", terrainOcclusion = \"no\", radSaturation = \"na\", cloudMask = \"all\", cloud = \"all\", cloudShadow = \"all\", snow = \"all\", cirrus = \"all\", droppedPixel = \"no\", water = \"all\", droppedFrame = \"no\", sensor = \"OLI\", legacy = \"collection1\" )"},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Encode QA Conditions to Integers — encodeQA","text":"fill Designated fill. Options: c(\"yes\", \"\", \"\"). terrainOcclusion Terrain induced occlusion. Options: c(\"yes\", \"\", \"\"). radSaturation Number bands contain radiometric saturation. Options: c(\"na\", \"low\", \"med\", \"high\", \"\") bands, 1-2 bands, 3-4 bands, 5 bands contain saturation. cloudMask Cloud mask. Options: c(\"yes\", \"\", \"\"). cloud Cloud confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). cloudShadow Cloud shadow confidence. Options: c(\"yes\", \"\", \"\"). snow Snow / ice confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). cirrus Cirrus confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). droppedPixel Dropped pixel. Options: c(\"yes\", \"\", \"\"). water Water confidence. Options: c(\"na\", \"low\", \"med\", \"high\", \"\"). droppedFrame Dropped frame. Options: c(\"yes\", \"\", \"\"). sensor Sensor encode. Options: c(\"OLI\", \"TIRS\", \"ETM+\", \"TM\", \"MSS\"). legacy Encoding systematic Options: c(\"collection1\", \"pre_collection\"). Default \"collection1\" Landsat Collection 1 8-bit quality designations. Use \"pre_collection\" imagery downloaded Collection 1 quality designations introduced","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Encode QA Conditions to Integers — encodeQA","text":"Returns Integer value QA values","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Encode QA Conditions to Integers — encodeQA","text":"currently populated bits available arguments.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Encode QA Conditions to Integers — encodeQA","text":"https://www.usgs.gov/landsat-missions/landsat-collection-1-level-1-quality-assessment-band Collection 1 quality designations (legacy = \"collection1\")","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/encodeQA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Encode QA Conditions to Integers — encodeQA","text":"","code":"encodeQA(snow = \"low\", cirrus = c(\"med\", \"high\"), cloud = \"high\") #> [1] 23136 23264 23392 23520 23152 23280 23408 23536"},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"estimates digital number (DN) pixel value *dark* objects visible wavelength range.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"","code":"estimateHaze( x, hazeBands, darkProp = 0.01, maxSlope = TRUE, plot = FALSE, returnTables = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"x SpatRaster previous result estimateHaze returnTables = TRUE estimate haze hazeBands Integer Character. Band number bandname estimate atmospheric haze (optional x contains one layer) darkProp Numeric. Proportion pixels estimated dark. maxSlope Logical. Use darkProp upper boundary search DN maximum slope histogram value. plot Logical. Option display histograms haze values returnTables Logical. Option return frequency table per layer. takes effect x SpatRaster. x result estimateHaze tables always returned.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"returnTables FALSE (default). vector length(hazeBands) containing estimated haze DNs returned. returnTables TRUE list two components returned. list element 'SHV' contains haze values, 'table' contains another list sampled frequency tables. latter can re-used try different darkProp thresholds without sample raster .","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"assumed radiation originating *dark* pixels due atmospheric haze reflectance surface (surface dark, .e. reflectance close zero). Hence, haze values estimates path radiance, can subtracted dark object subtraction (DOS) procedure (see radCor) Atmospheric haze affects almost exclusively visible wavelength range. Therefore, typically, want estimate haze blue, green red bands, occasionally also nir band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/estimateHaze.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze","text":"","code":"## Estimate haze for blue, green and red band haze <- estimateHaze(lsat, hazeBands = 1:3, plot = FALSE) haze #> B1_dn B2_dn B3_dn #> 55 19 12 ## Find threshold interactively #### Return the frequency tables for re-use #### avoids having to sample the Raster again and again haze <- estimateHaze(lsat, hazeBands = 1:3, returnTables = TRUE) ## Use frequency table instead of lsat and fiddle with haze <- estimateHaze(haze, hazeBands = 1:3, darkProp = .1, plot = FALSE) haze$SHV #> B1_dn B2_dn B3_dn #> 57 20 12"},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":null,"dir":"Reference","previous_headings":"","what":"Fractional Cover Analysis — fCover","title":"Fractional Cover Analysis — fCover","text":"fCover takes classified high resolution image, e.g. vegetation non-vegetation based Landsat calculates cover fractions pixels coarser resolution, e.g. MODIS.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fractional Cover Analysis — fCover","text":"","code":"fCover( classImage, predImage, nSamples = 1000, classes = 1, maxNA = 0, clamp = TRUE, model = \"rf\", tuneLength = 3, trControl = trainControl(method = \"cv\"), method = deprecated(), filename = NULL, overwrite = FALSE, verbose, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fractional Cover Analysis — fCover","text":"classImage high resolution SpatRaster containing landcover classification, e.g. obtained superClass. predImage coarse resolution SpatRaster fractional cover estimated. nSamples Integer. Number pixels sample predImage train regression model classes Integer. Classes fractional cover estimated (one ). maxNA Numeric. Maximal proportion NAs allowed training pixels. clamp Logical. Enforce results stay within [0,1] interval. Values <0 reset 0 values >1 1. model Character. model fit image regression. See train options. Defaults randomForest ('rf') tuneLength Integer. Number levels tuning parameters generated train. See Details train. trControl trainControl object, specifying resampling, validation etc. method DEPREACTED! favor trControl=trainControl(method=\"cv\") Resampling method parameter tuning. Defaults 10 fold cross-validation. See trainControl options. filename Character. Filename output raster file (optional). overwrite Logical. TRUE, filename overwritten. verbose Logical. Print progress information. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fractional Cover Analysis — fCover","text":"Returns list two elements: models contains fitted models evaluated tenfold cross-validation (caret train objects); fCover contains SpatRaster fractional cover layer requested class.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fractional Cover Analysis — fCover","text":"fCover gets pixel values high resolution classified image correspond randomly selected moderate resolution pixels calculates percent classified image pixels represent cover type interest. words, high resolution image pixel size 1m moderate resolution image pixel size 30m sampling process take block 900 1m resolution pixels correspond single 30m pixel calculate percentage 1m pixels forest. example, 600 forest pixels 300 non-forest pixels value given output pixel 0.67 since 67 fCover relies train() function caret package provides access huge number classifiers. Please see available options train. default classifier (randomForest) chose shown provide good results image regression hence recomended start one. choose different classifier, make sure can run regression mode. Many models require tuning certain parameters. , handled train caret package. tuneLength argument can specify many different values tuning parameter tested. Random Forest algorithm example can tuned varying mtry parameter. Hence, specifying tuneLength = 10, ten different levels mtry tested cross-validation scheme best-performing value chosen final model. total -data values block high resolution pixels greater maxNA included training data set since much missing data provide reliable cover percentage. -data proporton less maxNA -data pixels removed total number pixels calculating percent cover.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/fCover.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fractional Cover Analysis — fCover","text":"","code":"# \\donttest{ library(terra) library(caret) #> Loading required package: lattice ## Create fake input images agg.level <- 9 modis <- terra::aggregate(rlogo, agg.level) ## Perform an exemplary classification lc <- unsuperClass(rlogo, nClass=2) ## Calculate the true cover, which is of course only possible in this example, ## because the fake corse resolution imagery is exactly res(rlogo)*9 trueCover <- terra::aggregate(lc$map, agg.level, fun = function(x, ...){sum(x == 1, ...)/sum(!is.na(x))}) ## Run with randomForest and support vector machine (radial basis kernel) ## Of course the SVM is handicapped in this example, ## due to poor tuning (tuneLength) par(mfrow=c(2,3)) for(model in c(\"rf\", \"svmRadial\")){ fc <- fCover( classImage = lc$map , predImage = modis, classes=1, trControl = trainControl(method = \"cv\", number = 3), model=model, nSample = 50, tuneLength=2 ) ## How close is it to the truth? compare.rf <- trueCover - fc$map plot(fc$map, main = paste(\"Fractional Cover: Class 1\\nModel:\", model)) plot(compare.rf, main = \"Diffence\\n true vs. predicted\") plot(trueCover[],fc$map[], xlim = c(0,1), ylim =c(0,1), xlab = \"True Cover\", ylab = \"Predicted Cover\" ) abline(coef=c(0,1)) rmse <- sqrt(global(compare.rf^2, \"sum\", na.rm = TRUE))/ncell(compare.rf) r2 <- cor(trueCover[], fc$map[], \"complete.obs\") text(0.9,0.1, adj=1, labels = paste(c(\"RMSE:\",\"\\nR2:\"), round(unlist(c(rmse, r2)),3), collapse=\"\")) } ## Reset par par(mfrow=c(1,1)) # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":null,"dir":"Reference","previous_headings":"","what":"Fortify method for classes from the terra package. — fortifySpatRaster","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"Fortify method classes terra package.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"","code":"fortifySpatRaster(x, maxpixels = 50000)"},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"x SpatRaster object convert dataframe. maxpixels Integer. Maximum number pixels sample","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"Returns data.frame coordinates (x,y) corresponding raster values.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fortify method for classes from the terra package. — fortifySpatRaster","text":"","code":"r_df <- fortifySpatRaster(rlogo) head(r_df) #> x y red green blue #> 1 0.5 76.5 255 255 255 #> 2 1.5 76.5 255 255 255 #> 3 2.5 76.5 255 255 255 #> 4 3.5 76.5 255 255 255 #> 5 4.5 76.5 255 255 255 #> 6 5.5 76.5 255 255 255"},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract bandwise information from ImageMetaData — getMeta","title":"Extract bandwise information from ImageMetaData — getMeta","text":"accessor function quickly access information stored ImageMetaData, e.g. scale factor per band. Intended use imagery imported using stackMeta. return parameters using actual band order img.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract bandwise information from ImageMetaData — getMeta","text":"","code":"getMeta(img, metaData, what)"},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract bandwise information from ImageMetaData — getMeta","text":"img SpatRaster character vector band names. metaData ImageMetaData path meta data file. Character. Parameter extract. Either data descriptors, conversion parameters (see Details options)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract bandwise information from ImageMetaData — getMeta","text":"one c('CALRAD', 'CALBT', 'CALREF') data.frame returned bands rows (order corresponding img band order). Otherwise named numeric vector corresponding parameter returned (layernames names).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract bandwise information from ImageMetaData — getMeta","text":"Possible metadata parameters (argument): Data descriptors Conversion parameters","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract bandwise information from ImageMetaData — getMeta","text":"","code":"## Import example data mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") meta <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) ## Get integer scale factors getMeta(lsat_t, metaData = meta, what = \"SCALE_FACTOR\") #> B1_dn B2_dn B3_dn B4_dn B5_dn B6_dn B7_dn #> 1 1 1 1 1 1 1 ## Conversion factors for brightness temperature getMeta(\"B6_dn\", metaData = meta, what = \"CALBT\") #> K1 K2 #> B6_dn 607.76 1260.56 ## Conversion factors to top-of-atmosphere radiance ## Band order not corresponding to metaData order getMeta(lsat_t[[5:1]], metaData = meta, what = \"CALRAD\") #> offset gain #> B5_dn -0.49035 0.120 #> B4_dn -2.38602 0.876 #> B3_dn -2.21398 1.044 #> B2_dn -4.16220 1.322 #> B1_dn -2.19134 0.671 ## Get integer scale factors getMeta(lsat_t, metaData = meta, what = \"SCALE_FACTOR\") #> B1_dn B2_dn B3_dn B4_dn B5_dn B6_dn B7_dn #> 1 1 1 1 1 1 1 ## Get file basenames getMeta(lsat_t, metaData = meta, what = \"FILES\") #> B1_dn B2_dn #> \"LT52240631988227CUB02_B1.TIF\" \"LT52240631988227CUB02_B2.TIF\" #> B3_dn B4_dn #> \"LT52240631988227CUB02_B3.TIF\" \"LT52240631988227CUB02_B4.TIF\" #> B5_dn B6_dn #> \"LT52240631988227CUB02_B5.TIF\" \"LT52240631988227CUB02_B6.TIF\" #> B7_dn #> \"LT52240631988227CUB02_B7.TIF\""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract validation results from superClass objects — getValidation","title":"Extract validation results from superClass objects — getValidation","text":"Extract validation results superClass objects","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract validation results from superClass objects — getValidation","text":"","code":"getValidation(x, from = \"testset\", metrics = \"overall\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract validation results from superClass objects — getValidation","text":"x superClass object caret::confusionMatrix Character. 'testset' extracts results independent validation testset. 'cv' extracts cross-validation results. metrics Character. relevant classification mode (ignored regression models). Select 'overall' overall accuracy metrics, 'classwise' classwise metrics, 'confmat' confusion matrix 'caret' return whole caret::confusionMatrix object.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract validation results from superClass objects — getValidation","text":"Returns data.frame validation results. metrics = 'confmat' 'caret' return table full caret::confusionMatrix object, respectively.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/getValidation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract validation results from superClass objects — getValidation","text":"","code":"library(pls) #> #> Attaching package: ‘pls’ #> The following object is masked from ‘package:caret’: #> #> R2 #> The following object is masked from ‘package:stats’: #> #> loadings ## Fit classifier (splitting training into 70\\% training data, 30\\% validation data) train <- readRDS(system.file(\"external/trainingPoints_rlogo.rds\", package=\"RStoolbox\")) SC <- superClass(rlogo, trainData = train, responseCol = \"class\", model=\"pls\", trainPartition = 0.7) ## Independent testset-validation getValidation(SC) #> model validation Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull #> 1 pls testset 0.8888889 0.8333333 0.5175035 0.9971909 0.3333333 #> AccuracyPValue McnemarPValue #> 1 0.0009653 NaN getValidation(SC, metrics = \"classwise\") #> model validation class Sensitivity Specificity Pos.Pred.Value Neg.Pred.Value #> 1 pls testset A 1.0000000 0.8333333 0.75 1.0000000 #> 2 pls testset B 0.6666667 1.0000000 1.00 0.8571429 #> 3 pls testset C 1.0000000 1.0000000 1.00 1.0000000 #> Precision Recall F1 Prevalence Detection.Rate Detection.Prevalence #> 1 0.75 1.0000000 0.8571429 0.3333333 0.3333333 0.4444444 #> 2 1.00 0.6666667 0.8000000 0.3333333 0.2222222 0.2222222 #> 3 1.00 1.0000000 1.0000000 0.3333333 0.3333333 0.3333333 #> Balanced.Accuracy #> 1 0.9166667 #> 2 0.8333333 #> 3 1.0000000 ## Cross-validation based getValidation(SC, from = \"cv\") #> model validation Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull #> 1 pls cv 0.8571429 0.7857143 0.636576 0.969511 0.3333333 #> AccuracyPValue McnemarPValue #> 1 1.101588e-06 NaN"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot RasterLayers in ggplot with greyscale — ggR","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"Plot single layer imagery grey-scale. Can used SpatRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"","code":"ggR( img, layer = 1, maxpixels = 5e+05, alpha = 1, hue = 1, sat = 0, stretch = \"none\", quantiles = c(0.02, 0.98), ext = NULL, coord_equal = TRUE, ggLayer = FALSE, ggObj = TRUE, geom_raster = FALSE, forceCat = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"img SpatRaster layer Character numeric. Layername number. Can one layer, case layer plotted subplot. maxpixels Integer. Maximal number pixels sample. alpha Numeric. Transparency (0-1). hue Numeric. Hue value color calculation [0,1] (see hsv). Change need anything else greyscale. effective sat > 0. sat Numeric. Saturation value color calculation [0,1] (see hsv). Change need anything else greyscale. stretch Character. Either 'none', 'lin', 'hist', 'sqrt' 'log' stretch, linear, histogram, square-root logarithmic stretch. quantiles Numeric vector two elements. Min max quantiles stretch . Defaults 2% stretch, .e. c(0.02,0.98). ext Extent object crop image coord_equal Logical. Force addition coord_equal, .e. aspect ratio 1:1. Typically useful remote sensing data (depending projection), hence defaults TRUE. Note however, apply (ggLayer=FALSE). ggLayer Logical. Return ggplot layer must added existing ggplot. FALSE s stand-alone ggplot returned. ggObj Logical. Return stand-alone ggplot object (TRUE) just data.frame values colors geom_raster Logical. FALSE uses annotation_raster (good keep aestetic mappings free). TRUE uses geom_raster (aes(fill)). See Details. forceCat Logical. TRUE raster values forced categorical (converted factor needed).","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"img contains factor values annotation=TRUE, raster values automatically converted numeric order proceed brightness calculation. geom_raster argument switches default use annotation_raster geom_raster. difference two geom_raster performs meaningful mapping pixel values fill colour, annotation_raster simply adding picture plot. practice means whenever need legend raster use geom_raster = TRUE. also allows specify modify fill scale manually. advantage using annotation_raster (geom_raster = TRUE) can still use scale_fill* another variable. example add polygons map value fill colour. details theory behind aestetic mapping look ggplot2 manuals.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot RasterLayers in ggplot with greyscale — ggR","text":"","code":"library(ggplot2) library(terra) ## Simple grey scale annotation ggR(rlogo) ## With linear stretch contrast enhancement ggR(rlogo, stretch = \"lin\", quantiles = c(0.1,0.9)) ## ggplot with geom_raster instead of annotation_raster ## and default scale_fill* ggR(rlogo, geom_raster = TRUE) ## with different scale ggR(rlogo, geom_raster = TRUE) + scale_fill_gradientn(name = \"mojo\", colours = rainbow(10)) + ggtitle(\"**Funkadelic**\") ## Plot multiple layers # \\donttest{ ggR(lsat, 1:6, geom_raster=TRUE, stretch = \"lin\") + scale_fill_gradientn(colors=grey.colors(100), guide = \"none\") + theme(axis.text = element_text(size=5), axis.text.y = element_text(angle=90), axis.title=element_blank()) ## Don't plot, just return a data.frame df <- ggR(rlogo, ggObj = FALSE) head(df, n = 3) #> x y value layerName fill #> 1 0.5 76.5 255 red #FFFFFFFF #> 2 1.5 76.5 255 red #FFFFFFFF #> 3 2.5 76.5 255 red #FFFFFFFF ## Layermode (ggLayer=TRUE) data <- data.frame(x = c(0, 0:100,100), y = c(0,sin(seq(0,2*pi,pi/50))*10+20, 0)) ggplot(data, aes(x, y)) + ggR(rlogo, geom_raster= FALSE, ggLayer = TRUE) + geom_polygon(aes(x, y), fill = \"blue\", alpha = 0.4) + coord_equal(ylim=c(0,75)) ## Categorical data ## In this case you probably want to use geom_raster=TRUE ## in order to perform aestetic mapping (i.e. a meaningful legend) rc <- rlogo rc[] <- cut(rlogo[[1]][], seq(0,300, 50)) ggR(rc, geom_raster = TRUE) ## Legend cusomization etc. ... ggR(rc, geom_raster = TRUE) + scale_fill_continuous(labels=paste(\"Class\", 1:6)) # } ## Creating a nicely looking DEM with hillshade background terr <- terrain(srtm, c(\"slope\", \"aspect\")) hill <- shade(terr[[\"slope\"]], terr[[\"aspect\"]]) ggR(hill) ggR(hill) + ggR(srtm, geom_raster = TRUE, ggLayer = TRUE, alpha = 0.3) + scale_fill_gradientn(colours = terrain.colors(100), name = \"elevation\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":null,"dir":"Reference","previous_headings":"","what":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"Calculates RGB color composite raster plotting ggplot2. Optional values clipping stretching can used enhance imagery.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"","code":"ggRGB( img, r = 3, g = 2, b = 1, scale, maxpixels = 5e+05, stretch = \"none\", ext = NULL, limits = NULL, clipValues = \"limits\", quantiles = c(0.02, 0.98), ggObj = TRUE, ggLayer = FALSE, alpha = 1, coord_equal = TRUE, geom_raster = FALSE, nullValue = 0 )"},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"img SpatRaster r Integer character. Red layer x. Can set NULL, case red channel set zero. g Integer character. Green layer x. Can set NULL, case green channel set zero. b Integer character. Blue layer x. Can set NULL, case blue channel set zero. scale Numeric. Maximum possible pixel value (optional). Defaults 255 maximum value x larger 255 maxpixels Integer. Maximal number pixels used plotting. stretch Character. Either 'none', 'lin', 'hist', 'sqrt' 'log' stretch, linear, histogram, square-root logarithmic stretch. ext Extent SpatExtent object crop image limits Vector matrix. Can used reduce range values. Either vector two values bands (c(min, max)) 3x2 matrix min max values (columns) layer (rows). clipValues Matrix, numeric vector, string NA. Values reset range (limits) values . default ('limits') values reset limits. single value (e.g. NA) recycled lower/higher clippings, vector length two (c(min,max)) can used specify lower higher replace values, applied bands. two column matrix (typically three rows) can used fully control lower upper clipping values differently band. quantiles Numeric vector two elements. Min max quantiles stretch. Defaults 2% stretch, .e. c(0.02,0.98). ggObj Logical. TRUE ggplot2 object returned. FALSE data.frame coordinates color returned. ggLayer Logical. TRUE ggplot2 layer returned. useful want add existing ggplot2 object. Note TRUE & annotate = FALSE add scale_fill_identity() manually call ggplot(). alpha Numeric. Transparency (0-1). coord_equal Logical. Force addition coord_equal, .e. aspect ratio 1:1. Typically useful remote sensing data (depending projection), hence defaults TRUE. Note howver, apply (ggLayer=FALSE). geom_raster Logical. FALSE annotation_raster used, otherwise geom_raster()+scale_fill_identity used. Note use scale_fill* addition latter, already requires scale_fill_identity(). nullValue Numeric. Intensity value used NULL layers color compositing. E.g. set g=NULL fix green value 0.5 (defaults 0).","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"Functionality based plotRGB raster package.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/ggRGB.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB","text":"","code":"library(ggplot2) ggRGB(rlogo, r=1, g=2, b=3) ## Define minMax ranges ggRGB(rlogo, r=1,g=2, b=3, limits = matrix(c(100,150,10,200,50,255), ncol = 2, by = TRUE)) ## Perform stong linear contrast stretch ggRGB(rlogo, r = 1, g = 2, b = 3,stretch = \"lin\", quantiles = c(0.2, 0.8)) ## Use only two layers for color calculation ggRGB(rlogo, r = 1, g = 2, b = NULL) ## Return only data.frame df <- ggRGB(rlogo, ggObj = FALSE) head(df) #> x y fill #> 1 0.5 76.5 #FFFFFFFF #> 2 1.5 76.5 #FFFFFFFF #> 3 2.5 76.5 #FFFFFFFF #> 4 3.5 76.5 #FFFFFFFF #> 5 4.5 76.5 #FFFFFFFF #> 6 5.5 76.5 #FFFFFFFF ## Use in layer-mode, e.g. to add to another plot wave <- data.frame(x = c(0, 0:100,100), y = c(0,sin(seq(0,2*pi,pi/50))*10+20, 0)) p <- ggplot(wave, aes(x, y)) p + ggRGB(rlogo, ggLayer = TRUE) + geom_polygon(aes(x, y), fill = \"blue\", alpha = 0.4) + coord_equal(ylim=c(0,75))"},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":null,"dir":"Reference","previous_headings":"","what":"Image to Image Contrast Matching — histMatch","title":"Image to Image Contrast Matching — histMatch","text":"Performs image image contrast adjustments based histogram matching using empirical cumulative distribution functions images.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Image to Image Contrast Matching — histMatch","text":"","code":"histMatch( x, ref, xmask = NULL, refmask = NULL, nSamples = 1e+05, intersectOnly = TRUE, paired = TRUE, forceInteger = FALSE, returnFunctions = FALSE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Image to Image Contrast Matching — histMatch","text":"x SpatRaster. Source raster modified. ref SpatRaster. Reference raster, x matched. xmask RasterLayer SpatRaster. Mask layer x exclude pixels might distort histogram, .e. present ref. NA pixel xmask ignored (maskvalue = NA). refmask RasterLayer SpatRaster. Mask layer ref. NA pixel refmask ignored (maskvalue = NA). nSamples Integer. Number random samples image build histograms. intersectOnly Logical. TRUE sampling take place overlap extent two rasters. Otherwise full rasters used sampling. paired Logical. TRUE corresponding pixels used overlap. forceInteger Logical. Force integer output. returnFunctions Logical. TRUE matching functions returned instead applying x. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Image to Image Contrast Matching — histMatch","text":"SpatRaster x adjusted histogram ref. returnFunctions = TRUE list functions (one layer) returned instead.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Image to Image Contrast Matching — histMatch","text":"x ref must number layers.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Image to Image Contrast Matching — histMatch","text":"Richards Jia: Remote Sensing Digital Image Analysis. Springer, Berlin, Heidelberg, Germany, 439pp.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/histMatch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Image to Image Contrast Matching — histMatch","text":"","code":"library(ggplot2) library(terra) ## Original image a (+1 to prevent log(0)) img_a <- rlogo + 1 ## Degraded image b img_b <- log(img_a) ## Cut-off half the image (just for better display) img_b[, 1:50] <- NA ## Compare Images before histMatching ggRGB(img_a,1,2,3)+ ggRGB(img_b, 1,2,3, ggLayer = TRUE, stretch = \"lin\", q = 0:1) + geom_vline(aes(xintercept = 50))+ ggtitle(\"Img_a vs. Img_b\") #> Warning: data length [3927] is not a sub-multiple or multiple of the number of columns [101] ## Do histogram matching img_b_matched <- histMatch(img_b, img_a) ## Compare Images after histMatching ggRGB(img_a, 1, 2, 3)+ ggRGB(img_b_matched, 1, 2, 3, ggLayer = TRUE, stretch = \"lin\", q = 0:1) + geom_vline(aes(xintercept = 50))+ ggtitle(\"Img_a vs. Img_b_matched\") #> Warning: data length [3927] is not a sub-multiple or multiple of the number of columns [101] ## Histogram comparison opar <- par(mfrow = c(1, 3), no.readonly = TRUE) img_a[,1:50] <- NA redLayers <- c(img_a, img_b, img_b_matched)[[c(1,4,7)]] names(redLayers) <- c(\"img_a\", \"img_b\", \"img_b_matched\") hist(redLayers) ## Reset par par(opar)"},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":null,"dir":"Reference","previous_headings":"","what":"Landsat 5TM Example Data — lsat","title":"Landsat 5TM Example Data — lsat","text":"Subset Landsat 5 TM Scene: LT52240631988227CUB02 Contains seven bands DN format.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Landsat 5TM Example Data — lsat","text":"","code":"lsat"},{"path":"https://bleutner.github.io/RStoolbox/reference/lsat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Landsat 5TM Example Data — lsat","text":"","code":"ggRGB(lsat, stretch = \"sqrt\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":null,"dir":"Reference","previous_headings":"","what":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"mesma performs spectral mixture anlylsis (SMA) multiple endmember spectral mixture analysis (MESMA) multiband raster image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"","code":"mesma( img, em, method = \"NNLS\", iterate = 400, tolerance = 1e-08, n_models = NULL, sum_to_one = TRUE, ..., verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"img SpatRaster. Remote sensing imagery (usually hyperspectral). em Matrix data.frame spectral endmembers. Columns represent spectral bands (.e. columns correspond number bands img). Rows represent either single endmember per class (SMA) multiple endmembers per class (MESMA), column name class present, containing class name endmember belongs , e.g. \"water\" \"land\". See details . Number rows needs > 1. method Character. Select unmixing method. Currently, \"NNLS\" implemented. Default \"NNLS\". NNLS: applies non-negative least squares (NNLS) regression using sequential coordinate-wise algorithm (SCA) based Franc et al. (2005). iterate Integer. Set maximum iteration per pixel. Processing time increase iterations made possible. Default 400. tolerance Numeric. Tolerance limit representing nearly zero minimal number. Default 1e-8. n_models Logical. applies em contains column class. Defines many endmember combinations picked. Maximum minimum number endmembers class. Defaults amount rows em. sum_to_one Logical. Defines whether sum--one constraint applied probabilities endmember classes sum one (constraint covered NNLS) interpretable fractions. Defaults TRUE. get actual NNLS results, change FALSE. ... arguments passed writeRaster. verbose Logical. Prints progress messages execution.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"SpatRaster. object contain one band per class, value representing estimated probability respective endmember class per pixel, RMSE band. sum_to_one TRUE (default), values class bands can interpreted fractions per endmember class (0 1).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Argument em determines whether SMA (row representing single endmember per class) MESMA (multiple endmembers per class differentiate using class column) computed. multiple endmembers per class provided, mesma compute number SMA (determined argument n_models) multiple endmember combinations drawn em select best fit per pixel based lowest RMSE, based MESMA approach proposed Roberts et al. (1998).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Depending iterate tolerance settings selected endmembers, sum estimated probabilities per pixel varies around 1. NNLS account sum--one constraint. Use sum_to_one sum one post-NNLS. achieve best results, recommended adjust n_models accordance number endemembers per class provided em many endmember combinations possible (endmember used ) computed. models calculated, processing memory recourses needed.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Franc, V., Hlaváč, V., & Navara, M. (2005). Sequential coordinate-wise algorithm non-negative least squares problem. : International Conference Computer Analysis Images Patterns (pp. 407-414). Berlin, Heidelberg. Roberts, D. ., Gardner, M., Church, R., Ustin, S., Scheer, G., & Green, R. O. (1998). Mapping chaparral Santa Monica Mountains using multiple endmember spectral mixture models. Remote sensing environment, 65(3), 267-279.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"Jakob Schwalb-Willmann","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/mesma.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma","text":"","code":"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) # to perform a MESMA, use multiple endmembers per class, differntiating them # by a column named 'class': if (FALSE) { # \\dontrun{ 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) # 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) } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":null,"dir":"Reference","previous_headings":"","what":"Normalize Raster Images: Center and Scale — normImage","title":"Normalize Raster Images: Center and Scale — normImage","text":"pixel subtracts mean raster layer optionally divide standard deviation.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Normalize Raster Images: Center and Scale — normImage","text":"","code":"normImage(img, norm = TRUE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Normalize Raster Images: Center and Scale — normImage","text":"img SpatRaster. Image transform. Transformation performed separately layer. norm Logical. Perform normalization (scaling) addition centering, .e. divide standard deviation. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Normalize Raster Images: Center and Scale — normImage","text":"Returns SpatRaster number layers input layers layer centered optionally normalized.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/normImage.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Normalize Raster Images: Center and Scale — normImage","text":"","code":"library(terra) ## Load example data ## Normalization: Center and Scale rlogo_center_norm <- normImage(rlogo) hist(rlogo_center_norm) ## Centering rlogo_center <- normImage(rlogo, norm = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":null,"dir":"Reference","previous_headings":"","what":"One-hot encode a raster or vector — oneHotEncode","title":"One-hot encode a raster or vector — oneHotEncode","text":"Splits categorical raster layer (vector) multilayer raster (matrix).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"One-hot encode a raster or vector — oneHotEncode","text":"","code":"oneHotEncode(img, classes, background = 0, foreground = 1, na.rm = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"One-hot encode a raster or vector — oneHotEncode","text":"img SpatRaster integer/numeric vector containing multiple classes classes integer: vector classes extracted background integer: background value (default = 0) foreground integer: foreground value (default = 1) na.rm logical: TRUE, NAs coerced background value. ... arguments passed writeRaster. Ignored img SpatRaster, numeric/integer vector matrix","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"One-hot encode a raster or vector — oneHotEncode","text":"SpatRaster many layers classes. Pixels matching class interest set 1, backround values default set 0 (see background argument)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"One-hot encode a raster or vector — oneHotEncode","text":"","code":"# \\donttest{ sc <- unsuperClass(rlogo, nClasses = 3) ## one-hot encode sc_oneHot <- oneHotEncode(sc$map, classes = c(1,2,3)) ## check results sc_oneHot #> class : SpatRaster #> dimensions : 77, 101, 3 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : c_1, c_2, c_3 #> min values : 0, 0, 0 #> max values : 1, 1, 1 # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":null,"dir":"Reference","previous_headings":"","what":"Pan Sharpen Imagery / Image Fusion — panSharpen","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"provides different methods pan sharpening coarse resolution (typically multispectral) image higher reolution panchromatic image. Values pan-chromatic multispectral images must scale, (e.g. 0:1, DNs 0:255)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"","code":"panSharpen(img, pan, r, g, b, pc = 1, method = \"brovey\", norm = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"img SpatRaster. Coarse resolution multispectral image pan SpatRaster. High resolution image, typically panchromatic. r Character Integer. Red band img. relevant method!='pca' g Character Integer. Green band img. relevant method!='pca' b Character Integer. Blue band img. relevant method!='pca' pc Integer. relevant method = 'pca'. principal component replace. Usually first component (default). first component dominated something else brightness might worth try use second component. method Character. Choose method c(\"pca\", \"ihs\", \"brovey\"). norm Logical. Rescale pan image match 1st PC component. relevant method = 'pca'. TRUE min max matched 1st PC. FALSE pan histogram matched 1st PC.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"pan-sharpened SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"Pan sharpening options: method='pca': Performs pca using rasterPCA. first component swapped pan band PCA rotated backwards. method='ihs': Performs color space transform Intensity-Hue-Saturation space, swaps intensity histogram matched pan backwards transformation. method='brovey': Performs Brovey reweighting. Pan img must value scale (e.g. 0:1, 0:255) otherwise end psychodelic colors.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/panSharpen.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pan Sharpen Imagery / Image Fusion — panSharpen","text":"","code":"library(terra) library(ggplot2) ## Fake panchromatic image (30m resolution covering ## the visible range (integral from blue to red)) pan <- sum(lsat[[1:3]]) ggR(pan, stretch = \"lin\") ## Fake coarse resolution image (150m spatial resolution) lowResImg <- aggregate(lsat, 5) ## Brovey pan sharpening lowResImg_pan <- panSharpen(lowResImg, pan, r = 3, g = 2, b = 1, method = \"brovey\") lowResImg_pan #> class : SpatRaster #> dimensions : 310, 287, 3 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn_pan, B2_dn_pan, B3_dn_pan #> min values : 47.20757, 18.43627, 11.80072 #> max values : 191.12757, 87.47762, 85.39481 ## Plot ggRGB(lowResImg, stretch = \"lin\") + ggtitle(\"Original\") #> Warning: data length [3534] is not a sub-multiple or multiple of the number of columns [58] ggRGB(lowResImg_pan, stretch=\"lin\") + ggtitle(\"Pansharpened (Brovey)\") #> Warning: data length [88350] is not a sub-multiple or multiple of the number of columns [287]"},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":null,"dir":"Reference","previous_headings":"","what":"Pseudo-Invariant Features based Image Matching — pifMatch","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"Match one scene another based linear regression pseudo-invariant features (PIF).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"","code":"pifMatch( img, ref, method = \"cor\", quantile = 0.95, returnPifMap = TRUE, returnSimMap = TRUE, returnModels = FALSE )"},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"img SpatRaster. Image adjusted. ref SpatRaster. Reference image. method Method calculate pixel similarity. Options: euclidean distance ('ed'), spectral angle ('sam') pearson correlation coefficient ('cor'). quantile Numeric. Threshold quantile used identify PIFs returnPifMap Logical. Return binary raster map ot pixels identified pesudo-invariant features. returnSimMap Logical. Return similarity map well returnModels Logical. Return linear models along adjusted image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"Returns List adjusted image intermediate products (requested). img: adjusted image simMap: pixel-wise similarity map (returnSimMap = TRUE) pifMap: binary map pixels selected pseudo-invariant features (returnPifMap = TRUE) models: list linear models; one per layer (returnModels = TRUE)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"function consists three main steps: First, calculates pixel-wise similarity two rasters identifies pseudo-invariant pixels based similarity threshold. second step values pseudo-invariant pixels regressed linear model layer. Finally linear models applied pixels img, thereby matching reference scene. Pixel-wise similarity can calculated using one three methods: euclidean distance (method = \"ed\"), spectral angle (\"sam\") pearsons correlation coefficient (\"cor\"). threshold defined similarity quantile. Setting quantile=0.95 select pixels similarity 95% quantile pseudo-invariant features. Model fitting performed simple linear models (lm); fitting one model per layer.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pifMatch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pseudo-Invariant Features based Image Matching — pifMatch","text":"","code":"library(terra) ## Create fake example data ## In practice this would be an image from another acquisition date lsat_b <- log(lsat) ## Run pifMatch and return similarity layer, invariant features mask and models lsat_b_adj <- pifMatch(lsat_b, lsat, returnPifMap = TRUE, returnSimMap = TRUE, returnModels = TRUE) # \\donttest{ ## Pixelwise similarity ggR(lsat_b_adj$simMap, geom_raster = TRUE) ## Pesudo invariant feature mask ggR(lsat_b_adj$pifMap) ## Histograms of changes par(mfrow=c(1,3)) hist(lsat_b[[1]], main = \"lsat_b\") hist(lsat[[1]], main = \"reference\") hist(lsat_b_adj$img[[1]], main = \"lsat_b adjusted\") ## Model summary for first band summary(lsat_b_adj$models[[1]]) #> #> Call: #> lm(formula = ref ~ img, data = df) #> #> Residuals: #> Min 1Q Median 3Q Max #> -3.3904 -0.6021 0.0163 0.7107 24.6845 #> #> Coefficients: #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -324.9027 0.9321 -348.6 <2e-16 *** #> img 92.9473 0.2184 425.5 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 1.373 on 4447 degrees of freedom #> Multiple R-squared: 0.976,\tAdjusted R-squared: 0.976 #> F-statistic: 1.811e+05 on 1 and 4447 DF, p-value: < 2.2e-16 #> # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling `rhs(lhs)`.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"applies kmeans cluster model pixels raster. Useful want apply kmeans model scene scene B.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"","code":"# S3 method for class 'unsuperClass' predict(object, img, output = \"classes\", ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"object unsuperClass object img Raster object. Layernames must correspond layernames used train superClass model, .e. layernames original raster image. output Character. Either 'classes' (kmeans class; default) 'distances' (euclidean distance cluster center). ... arguments passed writeRaster, e.g. filename","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"Returns raster K-means distances base object passed arguments.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass","text":"","code":"## Load training data ## Perform unsupervised classification uc <- unsuperClass(rlogo, nClasses = 10) ## Apply the model to another raster map <- predict(uc, rlogo)"},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":null,"dir":"Reference","previous_headings":"","what":"Radiometric Calibration and Correction — radCor","title":"Radiometric Calibration and Correction — radCor","text":"Implements several different methods radiometric calibration correction Landsat data. can either specify metadata file, supply neccesary values manually. proper parametrization apref sdos work sensors well.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Radiometric Calibration and Correction — radCor","text":"","code":"radCor( img, metaData, method = \"apref\", bandSet = \"full\", hazeValues, hazeBands, atmosphere, darkProp = 0.01, clamp = TRUE, verbose )"},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Radiometric Calibration and Correction — radCor","text":"img SpatRaster metaData object class ImageMetaData path meta data (MTL) file. method Radiometric conversion/correction method used. currently four methods available (see Details): \"rad\", \"apref\", \"sdos\", \"dos\", \"costz\". bandSet Numeric character. original Landsat band numbers names form (\"B1\", \"B2\" etc). set 'full' bands solar (optical) region processed. hazeValues Numeric. Either vector dark DNs per hazeBand (method = 'sdos'); possibly estimated using estimateHaze. 'starting haze value' (DN) relative scattering models method = 'dos' 'costz'. provided, hazeValues estimated automated fashion hazeBands. Argument applies methods 'sdos', 'dos' 'costz'. hazeBands Character integer. Bands corresponding hazeValues (method = 'sdos') band select starting haze value ('dos' 'costz'). atmosphere Character. Atmospheric characteristics. estimated expicilty provided. Must one \"veryClear\", \"clear\", \"moderate\", \"hazy\" \"veryHazy\". darkProp Numeric. Estimated proportion dark pixels scene. Used automatic guessing hazeValues (typically one choose 1 2%). clamp Logical. Enforce valid value range. default reflectance forced stay within [0,1] radiance >= 0 replacing invalid values correspinding boundary, e.g. -0.1 become 0. verbose Logical. Print status information.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Radiometric Calibration and Correction — radCor","text":"SpatRaster top--atmosphere radiance (\\(W/(m^2 * srad * \\mu m)\\)), -satellite brightness temperature (K), top--atmosphere reflectance (unitless) corrected sun angle -surface reflectance (unitless).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Radiometric Calibration and Correction — radCor","text":"atmospheric correction methods (sdos, dos costz) apply optical (solar) region spectrum affect thermal band. Dark object subtraction approaches rely estimation atmospheric haze based *dark* pixels. Dark pixels assumed zero reflectance, hence name. assumed radiation originating *dark* pixels due atmospheric haze reflectance surface . folloiwing methods available: either \"dos\" \"costz\" selected, radCor use atmospheric haze decay model described Chavez (1989). Depending atmosphere following coefficients used: Landsat 8, values extra-terrestrial irradiation (esun) provided NASA. , however, neccessary DOS-based approaches. Therefore, values derived standard reference spectrum published Thuillier et al. (2003) using Landsat 8 OLI spectral response functions implemented sun-earth distances neglect earth's eccentricity. Instead use 100 year daily average (1979-2070).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Radiometric Calibration and Correction — radCor","text":"originally fork randcorr() function landsat package. version works SpatRasters hence suitable large rasters.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Radiometric Calibration and Correction — radCor","text":"S. Goslee (2011): Analyzing Remote Sensing Data R: landsat Package. Journal Statistical Software 43(4). G. Thuillier et al. (2003) SOLAR SPECTRAL IRRADIANCE 200 2400 nm MEASURED SOLSPEC SPECTROMETER ATLAS EURECA MISSIONS. Solar Physics 214(1): 1-22 (","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/radCor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Radiometric Calibration and Correction — radCor","text":"","code":"library(terra) ## Import meta-data and bands based on MTL file mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(mtlFile) lsat_t <- stackMeta(mtlFile) ## Convert DN to top of atmosphere reflectance and brightness temperature lsat_ref <- radCor(lsat_t, metaData = metaData, method = \"apref\") ## Correct DN to at-surface-reflecatance with DOS (Chavez decay model) lsat_sref <- radCor(lsat_t, metaData = metaData) ## Correct DN to at-surface-reflecatance with simple DOS ## Automatic haze estimation hazeDN <- estimateHaze(lsat_t, hazeBands = 1:4, darkProp = 0.01, plot = FALSE) lsat_sref <- radCor(lsat_t, metaData = metaData, method = \"sdos\", hazeValues = hazeDN, hazeBands = 1:4)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":null,"dir":"Reference","previous_headings":"","what":"Change Vector Analysis — rasterCVA","title":"Change Vector Analysis — rasterCVA","text":"Calculates angle magnitude change vectors. Dimensionality limited two bands per image.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change Vector Analysis — rasterCVA","text":"","code":"rasterCVA(x, y, tmf = NULL, nct = NULL, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change Vector Analysis — rasterCVA","text":"x SpatRaster two layers. reference/origin change calculations. rasters (y y) need correspond , .e. resolution, extent origin. y SpatRaster two layers. rasters (y y) need correspond , .e. resolution, extent origin. tmf Numeric. Threshold median factor (optional). Used calculate threshold magnitude pixels considered stable, .e. change. Calculated tmf * mean(magnitude[magnitude > 0]). nct Numeric. -change threshold (optional). Alternative tmf. Sets absolute threshold. Change magnitudes nct considered stable set NA. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Change Vector Analysis — rasterCVA","text":"Returns SpatRaster two layers: change vector angle change vector magnitude","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Change Vector Analysis — rasterCVA","text":"Change Vector Analysis (CVA) used identify spectral changes two identical scenes acquired different times. CVA limited two bands per image. pixel calculates change vector two-dimensional spectral space. example given pixel image B red nir band change vector calculated coordinate pairs: (red_A | nir_A) (red_B | nir_B). coordinate system defined order input bands: first band defines x-axis second band y-axis, respectively. Angles returned *degree* beginning 0 degrees pointing 'north', .e. y-axis, .e. second band.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterCVA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change Vector Analysis — rasterCVA","text":"","code":"library(terra) pca <- rasterPCA(lsat)$map ## Do change vector analysis cva <- rasterCVA(pca[[1:2]], pca[[3:4]]) cva #> class : SpatRaster #> dimensions : 310, 287, 2 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : angle, magnitude #> min values : 5.423571e-03, 0.1009387 #> max values : 3.599993e+02, 106.5000918"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":null,"dir":"Reference","previous_headings":"","what":"Multi-layer Pixel Entropy — rasterEntropy","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"Shannon entropy calculated pixel based layer values. used categorical / integer valued rasters.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"","code":"rasterEntropy(img, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"img SpatRaster ... additional arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"SpatRaster \"entropy\"","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"Entropy calculated -sum(p log(p)); p class frequency per pixel.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multi-layer Pixel Entropy — rasterEntropy","text":"","code":"re <- rasterEntropy(rlogo) ggR(re, geom_raster = TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":null,"dir":"Reference","previous_headings":"","what":"Principal Component Analysis for Rasters — rasterPCA","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Calculates R-mode PCA SpatRasters returns SpatRaster multiple layers PCA scores.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Principal Component Analysis for Rasters — rasterPCA","text":"","code":"rasterPCA( img, nSamples = NULL, nComp = nlyr(img), spca = FALSE, maskCheck = TRUE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Principal Component Analysis for Rasters — rasterPCA","text":"img SpatRaster. nSamples Integer NULL. Number pixels sample PCA fitting. NULL, pixels used. nComp Integer. Number PCA components return. spca Logical. TRUE, perform standardized PCA. Corresponds centered scaled input image. usually beneficial equal weighting layers. (FALSE default) maskCheck Logical. Masks pixels least one NA (default TRUE reccomended introduces slow-, see Details wise disable maskCheck). Takes effect nSamples NULL. ... arguments passed writeRaster, e.g. filename.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Returns named list containing PCA model object ($model) SpatRaster principal component layers ($object).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Principal Component Analysis for Rasters — rasterPCA","text":"Internally rasterPCA relies use princomp (R-mode PCA). nSamples given PCA calculated based random sample pixels predicted full raster. nSamples NULL covariance matrix calculated first used calculate princomp predict full raster. latter precise, since considers pixels, however, may slower calculating PCA subset pixels. Pixels missing values one bands set NA. built-check pixels can lead slow-rasterPCA. However, make sure know beforehand pixels either valid values NAs throughout layers can disable check setting maskCheck=FALSE speeds computation. Standardised PCA (SPCA) can useful imagery bands different dynamic ranges combined. SPC uses correlation matrix instead covariance matrix, effect using normalised bands unit variance.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rasterPCA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Principal Component Analysis for Rasters — rasterPCA","text":"","code":"library(ggplot2) library(reshape2) ggRGB(rlogo, 1,2,3) ## Run PCA set.seed(25) rpc <- rasterPCA(rlogo) rpc #> $call #> rasterPCA(img = rlogo) #> #> $model #> Call: #> princomp(cor = spca, covmat = covMat) #> #> Standard deviations: #> Comp.1 Comp.2 Comp.3 #> 124.814772 17.084151 1.456423 #> #> 3 variables and 7777 observations. #> #> $map #> class : SpatRaster #> dimensions : 77, 101, 3 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : PC1, PC2, PC3 #> min values : -323.1956, -46.42416, -9.374094 #> max values : 118.2781, 26.11958, 6.362937 #> #> attr(,\"class\") #> [1] \"rasterPCA\" \"RStoolbox\" ## Model parameters: summary(rpc$model) #> Importance of components: #> Comp.1 Comp.2 Comp.3 #> Standard deviation 124.8147718 17.08415063 1.456422555 #> Proportion of Variance 0.9814783 0.01838804 0.000133636 #> Cumulative Proportion 0.9814783 0.99986636 1.000000000 loadings(rpc$model) #> #> Loadings: #> Comp.1 Comp.2 Comp.3 #> red 0.594 0.507 0.625 #> green 0.585 0.262 -0.768 #> blue 0.553 -0.821 0.141 #> #> Comp.1 Comp.2 Comp.3 #> SS loadings 1.000 1.000 1.000 #> Proportion Var 0.333 0.333 0.333 #> Cumulative Var 0.333 0.667 1.000 ggRGB(rpc$map,1,2,3, stretch=\"lin\", q=0) if(require(gridExtra)){ plots <- lapply(1:3, function(x) ggR(rpc$map, x, geom_raster = TRUE)) grid.arrange(plots[[1]],plots[[2]], plots[[3]], ncol=2) } #> Loading required package: gridExtra"},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy import tool for EarthExplorer .csv export files — readEE","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"Imports tidies CSV files exported EarthExplorer data.frames annotates missing fields.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"","code":"readEE(x)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"x Character, Character list. One paths EarthExplorer export files.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"data.frame","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"EarthExplorer CSV file can produced search results page. results click 'export results' select 'comma (,) delimited'. Note subset columns imported deemed interesting. Please contact maintainer think omited column included.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readEE.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tidy import tool for EarthExplorer .csv export files — readEE","text":"","code":"library(ggplot2) ee <- readEE(system.file(\"external/EarthExplorer_LS8.txt\", package = \"RStoolbox\")) ## Scenes with cloud cover < 20% ee[ee$Cloud.Cover < 20,] #> Landsat.Scene.Identifier WRS.Path WRS.Row Data.Category Cloud.Cover #> 6 LC82240632015157LGN00 224 63 NOMINAL 13.20 #> 27 LC82240632014186LGN00 224 63 NOMINAL 15.94 #> 40 LC82240632013327LGN00 224 63 NOMINAL 13.19 #> 46 LC82240632013215LGN00 224 63 NOMINAL 14.72 #> 49 LC82240632013167LGN00 224 63 NOMINAL 6.35 #> Station.Identifier Day.Night Data.Type.Level.1 Date.Acquired Sun.Elevation #> 6 LGN DAY L1T 2015/06/06 51.98871 #> 27 LGN DAY L1T 2014/07/05 51.01591 #> 40 LGN DAY L1GT 2013/11/23 61.83434 #> 46 LGN DAY L1T 2013/08/03 54.43226 #> 49 LGN DAY L1T 2013/06/16 51.64735 #> Sun.Azimuth Geometric.RMSE.Model.X Geometric.RMSE.Model.Y #> 6 43.59274 6.244 5.663 #> 27 44.79093 5.452 5.420 #> 40 126.95937 0.000 0.000 #> 46 51.68815 5.631 5.840 #> 49 42.59918 6.377 5.862 #> Display.ID Ordering.ID #> 6 LC82240632015157LGN00 LC82240632015157LGN00 #> 27 LC82240632014186LGN00 LC82240632014186LGN00 #> 40 LC82240632013327LGN00 LC82240632013327LGN00 #> 46 LC82240632013215LGN00 LC82240632013215LGN00 #> 49 LC82240632013167LGN00 LC82240632013167LGN00 #> Download.Link #> 6 http://earthexplorer.usgs.gov/download/options/4923/LC82240632015157LGN00 #> 27 http://earthexplorer.usgs.gov/download/options/4923/LC82240632014186LGN00 #> 40 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013327LGN00 #> 46 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013215LGN00 #> 49 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013167LGN00 #> Browse.Link Date Doy Year Satellite Num #> 6 NA 2015-06-06 157 2015 LS8 8 #> 27 NA 2014-07-05 186 2014 LS8 8 #> 40 NA 2013-11-23 327 2013 LS8 8 #> 46 NA 2013-08-03 215 2013 LS8 8 #> 49 NA 2013-06-16 167 2013 LS8 8 ## Available time-series ggplot(ee) + geom_segment(aes(x = Date, xend = Date, y = 0, yend = 100 - Cloud.Cover, col = as.factor(Year))) + scale_y_continuous(name = \"Scene quality (% clear sky)\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Read Landsat MTL metadata files — readMeta","title":"Read Landsat MTL metadata files — readMeta","text":"Reads metadata deals legacy versions Landsat metadata files possible adds missing information (radiometric gain offset, earth-sun distance).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read Landsat MTL metadata files — readMeta","text":"","code":"readMeta(file, raw = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read Landsat MTL metadata files — readMeta","text":"file path Landsat MTL file (...MTL.txt) raw Logical. TRUE full raw metadata returned list. FALSE (default) important metadata homogenized standard format (ImageMetaData) information added.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read Landsat MTL metadata files — readMeta","text":"Object class ImageMetaData","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read Landsat MTL metadata files — readMeta","text":"","code":"## Example metadata file (MTL) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") ## Read metadata metaData <- readMeta(mtlFile) ## Summary summary(metaData) #> Scene: LT52240631988227CUB02 #> Satellite: LANDSAT5 #> Sensor: TM #> Date: 1988-08-14 #> Path/Row: 224/63 #> Projection: +proj=utm +zone=22 +units=m +datum=WGS84 +ellips=WGS84 #> Scene: PROJCRS[\"unknown\", #> BASEGEOGCRS[\"unknown\", #> DATUM[\"World Geodetic System 1984\", #> ELLIPSOID[\"WGS 84\",6378137,298.257223563, #> LENGTHUNIT[\"metre\",1]], #> ID[\"EPSG\",6326]], #> PRIMEM[\"Greenwich\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8901]]], #> CONVERSION[\"UTM zone 22N\", #> METHOD[\"Transverse Mercator\", #> ID[\"EPSG\",9807]], #> PARAMETER[\"Latitude of natural origin\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8801]], #> PARAMETER[\"Longitude of natural origin\",-51, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8802]], #> PARAMETER[\"Scale factor at natural origin\",0.9996, #> SCALEUNIT[\"unity\",1], #> ID[\"EPSG\",8805]], #> PARAMETER[\"False easting\",500000, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8806]], #> PARAMETER[\"False northing\",0, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8807]], #> ID[\"EPSG\",16022]], #> CS[Cartesian,2], #> AXIS[\"(E)\",east, #> ORDER[1], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]], #> AXIS[\"(N)\",north, #> ORDER[2], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]]] #> #> Data: #> FILES QUANTITY CATEGORY #> B1_dn LT52240631988227CUB02_B1.TIF dn image #> B2_dn LT52240631988227CUB02_B2.TIF dn image #> B3_dn LT52240631988227CUB02_B3.TIF dn image #> B4_dn LT52240631988227CUB02_B4.TIF dn image #> B5_dn LT52240631988227CUB02_B5.TIF dn image #> B6_dn LT52240631988227CUB02_B6.TIF dn image #> B7_dn LT52240631988227CUB02_B7.TIF dn image #> #> Available calibration parameters (gain and offset): #> \tdn -> radiance (toa) #> \tdn -> brightness temperature (toa) #>"},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":null,"dir":"Reference","previous_headings":"","what":"Read ENVI spectral libraries — readSLI","title":"Read ENVI spectral libraries — readSLI","text":"read/write support ENVI spectral libraries","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read ENVI spectral libraries — readSLI","text":"","code":"readSLI(path)"},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read ENVI spectral libraries — readSLI","text":"path Path spectral library file ending .sli.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read ENVI spectral libraries — readSLI","text":"spectral libraries read data.frame. first column contains wavelengths remaining columns contain spectra.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read ENVI spectral libraries — readSLI","text":"ENVI spectral libraries consist binary data file (.sli) corresponding header (.hdr, .sli.hdr) file.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/readSLI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read ENVI spectral libraries — readSLI","text":"","code":"## Example data sliFile <- system.file(\"external/vegSpec.sli\", package=\"RStoolbox\") sliTmpFile <- paste0(tempdir(),\"/vegetationSpectra.sli\") ## Read spectral library sli <- readSLI(sliFile) head(sli) #> wavelength veg_stressed veg_vital #> 1 350 0.008958003 0.008836994 #> 2 351 0.008910760 0.008909440 #> 3 352 0.008874181 0.008972186 #> 4 353 0.008847097 0.009025744 #> 5 354 0.008829174 0.009071405 #> 6 355 0.008819440 0.009109739 plot(sli[,1:2], col = \"orange\", type = \"l\") lines(sli[,c(1,3)], col = \"green\") ## Write to binary spectral library writeSLI(sli, path = sliTmpFile)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Image Rescaling — rescaleImage","title":"Linear Image Rescaling — rescaleImage","text":"performs linear shifts value ranges either match min/max another image (y) min max value (ymin ymax).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Image Rescaling — rescaleImage","text":"","code":"rescaleImage(x, y, xmin, xmax, ymin, ymax, forceMinMax = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Image Rescaling — rescaleImage","text":"x SpatRaster numeric vector. Image normalise. y SpatRaster numeric vector. Reference image. Optional. Used extract min max values ymin ymax missing. xmin Numeric. Min value x. Either single value one value per layer x. xmin provided extracted x. xmax Numeric. Max value x. Either single value one value per layer x. xmax provided extracted x. ymin Numeric. Min value y. Either single value one value per layer x. ymin provided extracted y. ymax Numeric. Max value y. Either single value one value per layer x. ymax provided extracted y. forceMinMax Logical. Forces update min max data slots x y. ... additional arguments passed terra::writeRaster()","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Image Rescaling — rescaleImage","text":"Returns SpatRaster dimensions input raster x shifted stretched new limits.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Image Rescaling — rescaleImage","text":"Providing xmin xmax values manually can useful raster contains variable known, fixed value range, e.g. NDVI -1 1 actual pixel values encompass entire range. providing xmin = -1 xmax = 1 values can rescaled range, e.g. 1 100 comparability rescaled NDVI scenes retained.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/rescaleImage.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Image Rescaling — rescaleImage","text":"","code":"lsat2 <- lsat - 1000 lsat2 #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : -946, -982, -989, -996, -998, -869, ... #> max values : -815, -913, -908, -873, -852, -854, ... ## Rescale lsat2 to match original lsat value range lsat2_rescaled <- rescaleImage(lsat2, lsat) lsat2_rescaled #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 54, 18, 11, 4, 2, 131, ... #> max values : 185, 87, 92, 127, 148, 146, ... ## Rescale lsat to value range [0,1] lsat2_unity <- rescaleImage(lsat2, ymin = 0, ymax = 1) lsat2_unity #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 0, 0, 0, 0, 0, 0, ... #> max values : 1, 1, 1, 1, 1, 1, ..."},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":null,"dir":"Reference","previous_headings":"","what":"Rlogo as SpatRaster — rlogo","title":"Rlogo as SpatRaster — rlogo","text":"Tiny example raster data used run examples.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rlogo as SpatRaster — rlogo","text":"","code":"rlogo"},{"path":"https://bleutner.github.io/RStoolbox/reference/rlogo.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rlogo as SpatRaster — rlogo","text":"","code":"ggRGB(rlogo,r = 1,g = 2,b = 3)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Set global options for RStoolbox — rsOpts","title":"Set global options for RStoolbox — rsOpts","text":"shortcut options(RStoolbox.*)","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set global options for RStoolbox — rsOpts","text":"","code":"rsOpts(verbose = NULL, idxdb = NULL)"},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set global options for RStoolbox — rsOpts","text":"verbose Logical. TRUE many functions print status messages current processing step. default verbose mode disabled. idxdb List. list conatins formal calculation spectral indices. Modify list pipe spectral index internal C++ calculation RStoolbox.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set global options for RStoolbox — rsOpts","text":"return, just setter verbosiness index-database RStoolbox package. latter, see example Rstoolbox::spectralIndices()","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/rsOpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set global options for RStoolbox — rsOpts","text":"","code":"rsOpts(verbose=TRUE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":null,"dir":"Reference","previous_headings":"","what":"Spectral Angle Mapper — sam","title":"Spectral Angle Mapper — sam","text":"Calculates angle spectral space pixels set reference spectra (endmembers) image classification based spectral similarity.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spectral Angle Mapper — sam","text":"","code":"sam(img, em, angles = FALSE, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spectral Angle Mapper — sam","text":"img SpatRaster. Remote sensing imagery. em Matrix data.frame endmembers. row contain endmember spectrum class, .e. columns correspond bands img. reccomended set rownames class names. angles Logical. TRUE RasterBrick containing one layer per endmember returned containing spectral angles. ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spectral Angle Mapper — sam","text":"SpatRaster angles = FALSE single Layer returned pixel assigned closest endmember class (integer pixel values correspond row order em.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spectral Angle Mapper — sam","text":"pixel spectral angle mapper calculates angle vector defined pixel values endmember vector. result one raster layer endmember containing spectral angle. smaller spectral angle similar pixel given endmember class. second step one can go ahead enforce thresholds maximum angles simply classify pixel similar endmember.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sam.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spectral Angle Mapper — sam","text":"","code":"library(terra) library(ggplot2) ## Sample endmember spectra ## First location is water, second is open agricultural vegetation pts <- data.frame(x = c(624720, 627480), y = c(-414690, -411090)) endmembers <- extract(lsat, pts) rownames(endmembers) <- c(\"water\", \"vegetation\") ## Calculate spectral angles lsat_sam <- sam(lsat, endmembers, angles = TRUE) plot(lsat_sam) ## Classify based on minimum angle lsat_sam <- sam(lsat, endmembers, angles = FALSE) ggR(lsat_sam, forceCat = TRUE, geom_raster=TRUE) + scale_fill_manual(values = c(\"blue\", \"green\"), labels = c(\"water\", \"vegetation\"))"},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":null,"dir":"Reference","previous_headings":"","what":"Save and Read RStoolbox Classification Results — saveRSTBX","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"Saves objects classes unsuperClass, superClass, rasterPCA fCover file. Useful archive fitted models.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"","code":"saveRSTBX(x, filename, format = \"raster\", ...) readRSTBX(filename)"},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"x RStoolbox object classes c(\"fCover\", \"rasterPCA\", \"superClass\", \"unsuperClass\") filename Character. Path filename. file extension ignored. format Character. Driver use raster file ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"output writeRSTBX least two files written disk: ) .rds file containing object b) raster file (depending driver choose can two files).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"saveRSTBX(): Save RStoolbox object file readRSTBX(): Read files saved saveRSTBX","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"files must kept directory read full object back R means readRSTBX. can move another location move ** (just like Shapefiles). case raster file(s) missing, readRSTBX still return object raster missing. writeRSTBX readRSTBX convenience wrappers around saveRDS, readRDS. means can read files created way also base functionality long move files. x$map SpatRaster object hence contains static link file disk.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Save and Read RStoolbox Classification Results — saveRSTBX","text":"","code":"if (FALSE) { # \\dontrun{ input <- rlogo ## Create filename file <- paste0(tempdir(), \"/test\", runif(1)) ## Run PCA rpc <- rasterPCA(input, nSample = 100) ## Save object saveRSTBX(rpc, filename=file) ## Which files were written? list.files(tempdir(), pattern = basename(file)) ## Re-read files re_rpc <- readRSTBX(file) ## Remove files file.remove(list.files(tempdir(), pattern = basename(file), full = TRUE)) } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":null,"dir":"Reference","previous_headings":"","what":"Sentinel 2 MSI L2A Scene — sen2","title":"Sentinel 2 MSI L2A Scene — sen2","text":"Contains 13 bands already converted spectral reflectances","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sentinel 2 MSI L2A Scene — sen2","text":"","code":"sen2"},{"path":"https://bleutner.github.io/RStoolbox/reference/sen2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sentinel 2 MSI L2A Scene — sen2","text":"","code":"ggRGB(sen2, r=4, g=3, b=2, stretch = \"lin\")"},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":null,"dir":"Reference","previous_headings":"","what":"Spectral Indices — spectralIndices","title":"Spectral Indices — spectralIndices","text":"Calculate suite multispectral indices NDVI, SAVI etc. efficient way via C++.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spectral Indices — spectralIndices","text":"","code":"spectralIndices( img, blue = NULL, green = NULL, red = NULL, nir = NULL, redEdge1 = NULL, redEdge2 = NULL, redEdge3 = NULL, swir1 = NULL, swir2 = NULL, swir3 = NULL, scaleFactor = 1, skipRefCheck = FALSE, indices = NULL, index = NULL, maskLayer = NULL, maskValue = 1, coefs = list(L = 0.5, G = 2.5, L_evi = 1, C1 = 6, C2 = 7.5, s = 1, swir2ccc = NULL, swir2coc = NULL), ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spectral Indices — spectralIndices","text":"img SpatRaster. Typically remote sensing imagery, classified. blue Character integer. Blue band. green Character integer. Green band. red Character integer. Red band. nir Character integer. Near-infrared band (700-1100nm). redEdge1 Character integer. Red-edge band (705nm) redEdge2 Character integer. Red-edge band (740nm) redEdge3 Character integer. Red-edge band (783nm) swir1 used swir2 Character integer. Short-wave-infrared band (1400-1800nm). swir3 Character integer. Short-wave-infrared band (2000-2500nm). scaleFactor Numeric. Scale factor conversion scaled reflectances [0,1] value range (applied reflectance/scaleFactor) Neccesary calculating EVI/EVI2 scaled reflectance values. skipRefCheck Logical. EVI/EVI2 calculated rough heuristic check, whether data inside [0,1]+/-0.5 (applying potential scaleFactor). invalid reflectances, e.g. clouds reflectance > 1 check result false positive skip EVI calculation. Use argument skip check cases *iff* sure data scaleFactor valid. indices Character. One spectral indices calculate (see Details). default (NULL) implemented indices given spectral bands provided calculated. index Character. Alias indices. maskLayer RasterLayer SpatRaster containing mask, e.g. clouds, pixels set NA. Alternatively layername -number can provided mask part img. maskValue Integer. Pixel value maskLayer masked output, .e. set NA calculated indices. coefs List coefficients (see Details). ... arguments filename etc. passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spectral Indices — spectralIndices","text":"SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spectral Indices — spectralIndices","text":"spectralIndices calculates indices one go C++, efficient calculating index separately (large rasters). default indices can calculated given specified indices calculated. want indices, use indices argument specify exactly indices calculated. See table bellow index names required bands. Index values outside valid value ranges (range exists) set NA. example pixel NDVI > 1 set NA. indices require additional parameters, slope soil line specified via list coefs argument. Although defaults sensible values, values like soil brightnes factor L SAVI adapted depending characteristics scene. coefficients : wavelength band names defined following Schowengertd 2007, p10. last column shows exemplarily Landsat 5 TM bands correspond wavelength range definition.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/spectralIndices.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Spectral Indices — spectralIndices","text":"","code":"library(ggplot2) library(terra) ## Calculate NDVI ndvi <- spectralIndices(lsat, red = \"B3_dn\", nir = \"B4_dn\", indices = \"NDVI\") ndvi #> class : SpatRaster #> dimensions : 310, 287, 1 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> name : NDVI #> min value : -0.5789474 #> max value : 0.7629630 ggR(ndvi, geom_raster = TRUE) + scale_fill_gradientn(colours = c(\"black\", \"white\")) # \\donttest{ ## Calculate all possible indices, given the provided bands ## Convert DNs to reflectance (required to calculate EVI and EVI2) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") lsat_ref <- radCor(lsat, mtlFile, method = \"apref\") #> 15:32:01 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn #> 15:32:01 | Thermal bands to convert to brightness temperature: B6_dn #> 15:32:01 | Processing thermal band(s) #> 15:32:01 | Processing radiance / reflectance SI <- spectralIndices(lsat_ref, red = \"B3_tre\", nir = \"B4_tre\") plot(SI) ## Custom Spectral Index Calculation (beta) (supports only bands right now...) # Get all indices idxdb <- getOption(\"RStoolbox.idxdb\") # Cutomize the RStoolbox index-database and overwrite the option cdb <- c(idxdb, CUSTOM = list( list(c(\"Mueller2024\", \"Super custom index\"), function(blue, red) {blue + red}))) rsOpts(idxdb = cdb) # Calculate the custom index, (also together with the provided ones) custom_ind <- spectralIndices(lsat, blue = 1, red = 3, nir = 4, indices = c(\"NDVI\", \"CUSTOM\")) # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":null,"dir":"Reference","previous_headings":"","what":"SRTM Digital Elevation Model — srtm","title":"SRTM Digital Elevation Model — srtm","text":"DEM Landsat example area taken SRTM v3 tile: s04_w050_1arc_v3.tif","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SRTM Digital Elevation Model — srtm","text":"","code":"srtm"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SRTM Digital Elevation Model — srtm","text":"","code":"ggR(srtm)"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":null,"dir":"Reference","previous_headings":"","what":"SRTM scene for the sen2 exemplary scene — srtm_sen2","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"DEM Sentinel 2 example area taken SRTM v4","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"","code":"srtm_sen2"},{"path":"https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SRTM scene for the sen2 exemplary scene — srtm_sen2","text":"","code":"ggR(srtm_sen2)"},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Import separate Landsat files into single stack — stackMeta","title":"Import separate Landsat files into single stack — stackMeta","text":"Reads Landsat MTL XML metadata files loads single Landsat Tiffs rasterStack. aware default stackMeta() import panchromatic bands thermal bands resolutions != 30m.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import separate Landsat files into single stack — stackMeta","text":"","code":"stackMeta(file, quantity = \"all\", category = \"image\", allResolutions = FALSE)"},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import separate Landsat files into single stack — stackMeta","text":"file Character. Path Landsat MTL metadata (*_MTL.txt) file Landsat CDR xml metadata file (*.xml). quantity Character vector. quantity returned. Options: digital numbers ('dn'), top atmosphere reflectance ('tre'), surface reflectance ('sre'), brightness temperature ('bt'), spectral index ('index'), quantities (''). category Character vector. category data return. Options 'image': image data, 'pan': panchromatic image, 'index': multiband indices, 'qa' quality flag bands, '': categories. allResolutions Logical. TRUE list returned length = unique spatial resolutions. argument introduced maintain backward compatibility switched TRUE upcoming release. Please base new code terra.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Import separate Landsat files into single stack — stackMeta","text":"Returns one single SpatRaster comprising requested bands. allResolutions = TRUE ** different resolution layers (e.g. 15m panchromatic band along wit 30m imagery) list RasterStacks returned.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Import separate Landsat files into single stack — stackMeta","text":"aware default stackMeta() import panchromatic bands thermal bands resolutions != 30m. Use allResolutions argument import layers. Note nowadays USGS uses cubic convolution resample TIR bands 30m resolution.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/stackMeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Import separate Landsat files into single stack — stackMeta","text":"","code":"## Example metadata file (MTL) mtlFile <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") ## Read metadata metaData <- readMeta(mtlFile) summary(metaData) #> Scene: LT52240631988227CUB02 #> Satellite: LANDSAT5 #> Sensor: TM #> Date: 1988-08-14 #> Path/Row: 224/63 #> Projection: +proj=utm +zone=22 +units=m +datum=WGS84 +ellips=WGS84 #> Scene: PROJCRS[\"unknown\", #> BASEGEOGCRS[\"unknown\", #> DATUM[\"World Geodetic System 1984\", #> ELLIPSOID[\"WGS 84\",6378137,298.257223563, #> LENGTHUNIT[\"metre\",1]], #> ID[\"EPSG\",6326]], #> PRIMEM[\"Greenwich\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8901]]], #> CONVERSION[\"UTM zone 22N\", #> METHOD[\"Transverse Mercator\", #> ID[\"EPSG\",9807]], #> PARAMETER[\"Latitude of natural origin\",0, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8801]], #> PARAMETER[\"Longitude of natural origin\",-51, #> ANGLEUNIT[\"degree\",0.0174532925199433], #> ID[\"EPSG\",8802]], #> PARAMETER[\"Scale factor at natural origin\",0.9996, #> SCALEUNIT[\"unity\",1], #> ID[\"EPSG\",8805]], #> PARAMETER[\"False easting\",500000, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8806]], #> PARAMETER[\"False northing\",0, #> LENGTHUNIT[\"metre\",1], #> ID[\"EPSG\",8807]], #> ID[\"EPSG\",16022]], #> CS[Cartesian,2], #> AXIS[\"(E)\",east, #> ORDER[1], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]], #> AXIS[\"(N)\",north, #> ORDER[2], #> LENGTHUNIT[\"metre\",1, #> ID[\"EPSG\",9001]]]] #> #> Data: #> FILES QUANTITY CATEGORY #> B1_dn LT52240631988227CUB02_B1.TIF dn image #> B2_dn LT52240631988227CUB02_B2.TIF dn image #> B3_dn LT52240631988227CUB02_B3.TIF dn image #> B4_dn LT52240631988227CUB02_B4.TIF dn image #> B5_dn LT52240631988227CUB02_B5.TIF dn image #> B6_dn LT52240631988227CUB02_B6.TIF dn image #> B7_dn LT52240631988227CUB02_B7.TIF dn image #> #> Available calibration parameters (gain and offset): #> \tdn -> radiance (toa) #> \tdn -> brightness temperature (toa) #> ## Load rasters based on metadata file lsat <- stackMeta(mtlFile) lsat #> class : SpatRaster #> dimensions : 310, 287, 7 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / UTM zone 22N (EPSG:32622) #> sources : LT52240631988227CUB02_B1.TIF #> LT52240631988227CUB02_B2.TIF #> LT52240631988227CUB02_B3.TIF #> ... and 4 more source(s) #> names : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, ... #> min values : 54, 18, 11, 4, 2, 131, ... #> max values : 185, 87, 92, 127, 148, 146, ..."},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Supervised Classification — superClass","title":"Supervised Classification — superClass","text":"Supervised classification classification regression mode based vector training data (points polygons).","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Supervised Classification — superClass","text":"","code":"superClass( img, trainData, valData = NULL, responseCol = NULL, nSamples = 1000, nSamplesV = 1000, polygonBasedCV = FALSE, trainPartition = NULL, model = \"rf\", tuneLength = 3, kfold = 5, minDist = 2, mode = \"classification\", predict = TRUE, predType = \"raw\", filename = NULL, verbose, overwrite = TRUE, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Supervised Classification — superClass","text":"img SpatRaster. Typically remote sensing imagery, classified. trainData sf sp spatial vector data containing training locations (POINTs,POLYGONs). valData Ssf sp spatial vector data containing validation locations (POINTs,POLYGONs) (optional). responseCol Character integer giving column trainData, contains response variable. Can omitted, trainData one column. nSamples Integer. Number samples per land cover class. NULL pixels covered training polygons used (memory intensive!). Ignored trainData consists POINTs. nSamplesV Integer. Number validation samples per land cover class. NULL pixels covered validation polygons used (memory intensive!). Ignored valData consists POINTs. polygonBasedCV Logical. TRUE model tuning cross-validation conducted per-polygon basis. Use deal overfitting issues. affect training data supplied SpatialPointsDataFrames. trainPartition Numeric. Partition (polygon based) trainData goes training data set zero one. Ignored valData provided. model Character. model use. See train options. Defaults randomForest ('rf'). addition standard caret models, maximum likelihood classification available via model = 'mlc'. tuneLength Integer. Number levels tuning parameter (see train details). kfold Integer. Number cross-validation resamples model tuning. minDist Numeric. Minumum distance training validation data, e.g. minDist=1 clips validation polygons ensure minimal distance one pixel (pixel size according img) next training polygon. Requires data carry valid projection information. mode Character. Model type: 'regression' 'classification'. predict Logical. Produce map (TRUE, default) fit validate model (FALSE). predType Character. Type final output raster. Either \"raw\" class predictions \"prob\" class probabilities. Class probabilities available classification models (predict.train). filename Path output file (optional). NULL, standard raster handling apply, .e. storage either memory raster temp directory. verbose Logical. prints progress statistics execution overwrite logical. Overwrite spatial prediction raster already exists. ... arguments passed train","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Supervised Classification — superClass","text":"superClass object (effectively list) containing: $model: fitted model $modelFit: model fit statistics $training: indexes samples used training $validation: list $performance: performance estimates based independent validation (confusion matrix etc.) $validationSamples: actual pixel coordinates plus reference predicted values used validation $validationGeometry: validation polygpns (clipped mindist training geometries) $map: predicted raster $classMapping: data.frame containing integer <-> label mapping","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Supervised Classification — superClass","text":"Note superClass automatically loads lattice randomForest package. SuperClass performs following steps: Ensure non-overlap training validation data. neccesary avoid biased performance estimates. minimum distance (minDist) pixels can provided enforce given distance training validation data. Sample training coordinates. trainData (valData present) polygons superClass calculate area per polygon sample nSamples locations per class within polygons. number samples per individual polygon scales polygon area, .e. bigger polygon, samples. Split training/validation valData provided (reccomended) samples polygons held-used model fitting validation. trainPartition provided trainingPolygons divided training polygons validation polygons. Extract raster data predictor values sample pixels extracted img Fit model. Using caret::train sampled training data model fit, including parameter tuning (tuneLength) kfold cross-validation. polygonBasedCV=TRUE define cross-validation folds based polygons (reccomended) otherwise performed per-pixel basis. Predict classes pixels img based final model. Validate model independent validation data.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/superClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Supervised Classification — superClass","text":"","code":"library(RStoolbox) library(caret) library(randomForest) #> randomForest 4.7-1.2 #> Type rfNews() to see new features/changes/bug fixes. #> #> Attaching package: ‘randomForest’ #> The following object is masked from ‘package:gridExtra’: #> #> combine #> The following object is masked from ‘package:ggplot2’: #> #> margin library(e1071) #> #> Attaching package: ‘e1071’ #> The following object is masked from ‘package:terra’: #> #> interpolate library(terra) train <- readRDS(system.file(\"external/trainingPoints_rlogo.rds\", package=\"RStoolbox\")) ## Plot training data olpar <- par(no.readonly = TRUE) # back-up par par(mfrow=c(1,2)) colors <- c(\"yellow\", \"green\", \"deeppink\") plotRGB(rlogo) plot(train, add = TRUE, col = colors[train$class], pch = 19) ## Fit classifier (splitting training into 70\\% training data, 30\\% validation data) SC <- superClass(rlogo, trainData = train, responseCol = \"class\", model = \"rf\", tuneLength = 1, trainPartition = 0.7) #> 15:32:05 | Begin sampling training data #> 15:32:05 | Starting to fit model #> 15:32:05 | Starting spatial predict #> 15:32:05 | Begin validation #> ******************** Model summary ******************** #> Random Forest #> #> 21 samples #> 3 predictor #> 3 classes: 'A', 'B', 'C' #> #> No pre-processing #> Resampling: Cross-Validated (5 fold) #> Summary of sample sizes: 16, 16, 18, 17, 17 #> Resampling results: #> #> Accuracy Kappa #> 1 1 #> #> Tuning parameter 'mtry' was held constant at a value of 1 #> [[1]] #> TrainAccuracy TrainKappa method #> 1 1 1 rf #> #> [[2]] #> Cross-Validated (5 fold) Confusion Matrix #> #> (entries are average cell counts across resamples) #> #> Reference #> Prediction A B C #> A 1.4 0.0 0.0 #> B 0.0 1.4 0.0 #> C 0.0 0.0 1.4 #> #> Accuracy (average) : 1 #> #> #> ******************** Validation summary ******************** #> Confusion Matrix and Statistics #> #> Reference #> Prediction A B C #> A 3 0 0 #> B 0 3 0 #> C 0 0 3 #> #> Overall Statistics #> #> Accuracy : 1 #> 95% CI : (0.6637, 1) #> No Information Rate : 0.3333 #> P-Value [Acc > NIR] : 5.081e-05 #> #> Kappa : 1 #> #> Mcnemar's Test P-Value : NA #> #> Statistics by Class: #> #> Class: A Class: B Class: C #> Sensitivity 1.0000 1.0000 1.0000 #> Specificity 1.0000 1.0000 1.0000 #> Pos Pred Value 1.0000 1.0000 1.0000 #> Neg Pred Value 1.0000 1.0000 1.0000 #> Prevalence 0.3333 0.3333 0.3333 #> Detection Rate 0.3333 0.3333 0.3333 #> Detection Prevalence 0.3333 0.3333 0.3333 #> Balanced Accuracy 1.0000 1.0000 1.0000 SC #> superClass results #> ************ Validation ************** #> $validation #> Confusion Matrix and Statistics #> #> Reference #> Prediction A B C #> A 3 0 0 #> B 0 3 0 #> C 0 0 3 #> #> Overall Statistics #> #> Accuracy : 1 #> 95% CI : (0.6637, 1) #> No Information Rate : 0.3333 #> P-Value [Acc > NIR] : 5.081e-05 #> #> Kappa : 1 #> #> Mcnemar's Test P-Value : NA #> #> Statistics by Class: #> #> Class: A Class: B Class: C #> Sensitivity 1.0000 1.0000 1.0000 #> Specificity 1.0000 1.0000 1.0000 #> Pos Pred Value 1.0000 1.0000 1.0000 #> Neg Pred Value 1.0000 1.0000 1.0000 #> Prevalence 0.3333 0.3333 0.3333 #> Detection Rate 0.3333 0.3333 0.3333 #> Detection Prevalence 0.3333 0.3333 0.3333 #> Balanced Accuracy 1.0000 1.0000 1.0000 #> #> *************** Map ****************** #> $map #> class : SpatRaster #> dimensions : 77, 101, 1 (nrow, ncol, nlyr) #> resolution : 1, 1 (x, y) #> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> name : class_supervised #> min value : 1 #> max value : 3 ## Plots plot(SC$map, col = colors, legend = FALSE, axes = FALSE, box = FALSE) legend(1,1, legend = levels(train$class), fill = colors , title = \"Classes\", horiz = TRUE, bty = \"n\") par(olpar) # reset par"},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":null,"dir":"Reference","previous_headings":"","what":"Tasseled Cap Transformation — tasseledCap","title":"Tasseled Cap Transformation — tasseledCap","text":"Calculates brightness, greenness wetness multispectral imagery. Currently implemented Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5 RapidEye.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tasseled Cap Transformation — tasseledCap","text":"","code":"tasseledCap(img, sat, ...)"},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tasseled Cap Transformation — tasseledCap","text":"img SpatRaster. Input image. Band order must correspond sensor specifications (see Details Examples) sat Character. Sensor; one : c(\"Landsat4TM\", \"Landsat5TM\", \"Landsat7ETM\", \"Landsat8OLI\", \"MODIS\", \"QuickBird\", \"Spot5\", \"RapidEye\"). Case irrelevant. ... arguments passed writeRaster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tasseled Cap Transformation — tasseledCap","text":"Returns SpatRaster thee bands: brigthness, greenness, (soil) wetness.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tasseled Cap Transformation — tasseledCap","text":"Currently implemented: Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5, RapdiEye. Input data must top atmosphere reflectance. Moreover, bands must provided ascending order listed table . Irrelevant bands, Landsat Thermal Bands QuickBird/Spot5 Panchromatic Bands must omitted. Required bands :","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Tasseled Cap Transformation — tasseledCap","text":"Crist (1985) \"TM Tasseled Cap Equivalent Transformation Reflectance Factor Data.\" Remote Sensing Environment 17 (3): 301-306 Huang et al. (2002) \"Derivation Tasselled Cap Transformation Based Landsat 7 -Satellite Reflectance.\" International Journal Remote Sensing 23 (8): 1741-1748 Baig et al. (2014) \"Derivation Tasselled Cap Transformation Based Landsat 8 -Satellite Reflectance.\" Remote Sensing Letters 5 (5): 423-431. Lobser et al. (2007) \"MODIS Tasselled Cap: Land Cover Characteristics Expressed Transformed MODIS Data.\" International Journal Remote Sensing 28 (22): 5079-5101. Yarbrough et al. (2005) \"QuickBird 2 tasseled cap transform coefficients: comparison derivation methods.\" Pecora 16 Global Priorities Land Remote Sensing: 23-27. Ivits et al. (2008) \"Orthogonal transformation segmented SPOT5 images.\" Photogrammetric Engineering & Remote Sensing 74 (11): 1351-1364. Schoenert et al. (2014) \"Derivation tasseled cap coefficients RapidEye data.\" Earth Resources Environmental Remote Sensing/GIS Applications V (9245): 92450Qs.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/tasseledCap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tasseled Cap Transformation — tasseledCap","text":"","code":"library(terra) ## Run tasseled cap (exclude thermal band 6) lsat_tc <- tasseledCap(lsat[[c(1:5,7)]], sat = \"Landsat5TM\") lsat_tc #> class : SpatRaster #> dimensions : 310, 287, 3 (nrow, ncol, nlyr) #> resolution : 30, 30 (x, y) #> extent : 619395, 628005, -419505, -410205 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=utm +zone=22 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs #> source(s) : memory #> names : brightness, greenness, wetness #> min values : 33.0776, -21.2454, 10.9682 #> max values : 254.0931, 69.6422, 122.4285 plot(lsat_tc)"},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":null,"dir":"Reference","previous_headings":"","what":"Topographic Illumination Correction — topCor","title":"Topographic Illumination Correction — topCor","text":"account correct changes illumination due terrain elevation.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Topographic Illumination Correction — topCor","text":"","code":"topCor( img, dem, metaData, solarAngles = c(), method = \"C\", stratImg = NULL, nStrat = 5, illu, ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Topographic Illumination Correction — topCor","text":"img SpatRaster. Imagery correct dem SpatRaster. Either digital elevation model RasterLayer RasterStack/Brick pre-calculated slope aspect (see terrain) case layers must named 'slope' 'aspect'. Must dimensions img. metaData Character, ImageMetaData. Either path Landsat meta-data file (MTL) ImageMetaData object (see readMeta) solarAngles Numeric vector containing sun azimuth sun zenith (radians order). needed metaData provided method Character. One c(\"cos\", \"avgcos\", \"minnaert\", \"C\", \"stat\", \"illu\"). Choosing 'illu' return local illumination map. stratImg RasterLayer SpatRaster define strata, e.g. NDVI. string 'slope' case stratification nStrat slope classes. relevant method = 'minnaert'. nStrat Integer. Number bins quantiles stratify . bin less 50 samples merged next bin. relevant method = 'minnaert'. illu SpatRaster. Optional pre-calculated ilumination map. Run topCor method=\"illu\" calculate ilumination map ... arguments passed writeRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Topographic Illumination Correction — topCor","text":"SpatRaster","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Topographic Illumination Correction — topCor","text":"detailed discussion various approaches please see Riano et al. (2003). minnaert correction can stratified different landcover characteristics. stratImg = 'slope' analysis stratified slope, .e. slope values divided nStrat classes correction coefficient k calculated applied separately slope class. alternative stratify vegetation index case additional raster layer provided via stratImg argument.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Topographic Illumination Correction — topCor","text":"Riano et al. (2003) Assessment different topographic correction Landsat-TM data mapping vegetation types. IEEE Transactions Geoscience Remote Sensing.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/topCor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Topographic Illumination Correction — topCor","text":"","code":"## Load example data metaData <- system.file(\"external/landsat/LT52240631988227CUB02_MTL.txt\", package=\"RStoolbox\") metaData <- readMeta(metaData) ## Minnaert correction, solar angles from metaData lsat_minnaert <- topCor(lsat, dem = srtm, metaData = metaData, method = \"minnaert\") #> 15:32:06 | Calculate slope and aspect #> 15:32:06 | Calculate illumination map #> 15:32:06 | Correct imagery #> 15:32:06 | Estimate coefficients ## C correction, solar angles provided manually lsat_C <- topCor(lsat, dem = srtm, solarAngles = c(1.081533, 0.7023922), method = \"C\") #> 15:32:07 | Calculate slope and aspect #> 15:32:07 | Calculate illumination map #> 15:32:07 | Correct imagery #> 15:32:07 | Estimate coefficients"},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":null,"dir":"Reference","previous_headings":"","what":"Unsupervised Classification — unsuperClass","title":"Unsupervised Classification — unsuperClass","text":"Unsupervised clustering SpatRaster data using kmeans clustering","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unsupervised Classification — unsuperClass","text":"","code":"unsuperClass( img, nSamples = 10000, nClasses = 5, nStarts = 25, nIter = 100, norm = FALSE, clusterMap = TRUE, algorithm = \"Hartigan-Wong\", output = \"classes\", ... )"},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unsupervised Classification — unsuperClass","text":"img SpatRaster. nSamples Integer. Number random samples draw fit cluster map. relevant clusterMap = TRUE. nClasses Integer. Number classes. nStarts Integer. Number random starts kmeans algorithm. nIter Integer. Maximal number iterations allowed. norm Logical. TRUE normalize img first using normImage. Normalizing beneficial predictors different scales. clusterMap Logical. Fit kmeans model random subset img (see Details). algorithm Character. kmeans algorithm. One c(\"Hartigan-Wong\", \"Lloyd\", \"MacQueen\") output Character. Either 'classes' (kmeans class; default) 'distances' (euclidean distance cluster center). ... arguments passed writeRaster, e.g. filename","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Unsupervised Classification — unsuperClass","text":"Returns RStoolbox::unsuperClass object, list containing kmeans model ($model) raster map ($map). output = \"classes\", $map contains SpatRaster discrete classes (kmeans clusters); output = \"distances\" $map contains SpatRaster, `nClasses` layers, layer maps euclidean distance corresponding class centroid.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Unsupervised Classification — unsuperClass","text":"Clustering done using kmeans. can done pixels image (clusterMap=FALSE), however can slow memory safe. Therefore large raster data (> memory), typically case remote sensing imagery advisable choose clusterMap=TRUE (default). means kmeans cluster model calculated based random subset pixels (nSamples). distance ** pixels cluster centers calculated stepwise fashion using predict. Class assignment based minimum euclidean distance cluster centers. solution kmeans algorithm often depends initial configuration class centers chosen randomly. Therefore, kmeans usually run multiple random starting configurations order find convergent solution different starting configurations. nStarts argument allows specify many random starts conducted.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/unsuperClass.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Unsupervised Classification — unsuperClass","text":"","code":"if (FALSE) { # \\dontrun{ library(terra) input <- rlogo ## Plot olpar <- par(no.readonly = TRUE) # back-up par par(mfrow=c(1,2)) plotRGB(input) ## Run classification set.seed(25) unC <- unsuperClass(input, nSamples = 100, nClasses = 5, nStarts = 5) unC ## Plots colors <- rainbow(5) plot(unC$map, col = colors, legend = FALSE, axes = FALSE, box = FALSE) legend(1,1, legend = paste0(\"C\",1:5), fill = colors, title = \"Classes\", horiz = TRUE, bty = \"n\") ## Return the distance of each pixel to each class centroid unC <- unsuperClass(input, nSamples = 100, nClasses = 3, output = \"distances\") unC ggR(unC$map, 1:3, geom_raster = TRUE) par(olpar) # reset par } # }"},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":null,"dir":"Reference","previous_headings":"","what":"Map accuracy assessment — validateMap","title":"Map accuracy assessment — validateMap","text":"validate map classification regression model. can useful update accuracy assessment filtering, e.g. minimum mapping unit.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Map accuracy assessment — validateMap","text":"","code":"validateMap( map, valData, responseCol, nSamplesV = 500, mode = \"classification\", classMapping = NULL )"},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Map accuracy assessment — validateMap","text":"map SpatRaster. classified map. valData sf object validation data (POLYGONs POINTs). responseCol Character. Column containing validation data attribute table valData. nSamplesV Integer. Number pixels sample validation (applies polygons). mode Character. Either 'classification' 'regression'. classMapping optional data.frame columns 'class' 'classID' defining mapping raster integers class names.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Map accuracy assessment — validateMap","text":"Returns structured list includng preformance confusion-matrix validated input data","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/validateMap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Map accuracy assessment — validateMap","text":"","code":"library(caret) library(terra) ## Training data poly <- readRDS(system.file(\"external/trainingPolygons_lsat.rds\", package=\"RStoolbox\")) ## Split training data in training and validation set (50%-50%) splitIn <- createDataPartition(poly$class, p = .5)[[1]] train <- poly[splitIn,] val <- poly[-splitIn,] ## Classify (deliberately poorly) sc <- superClass(lsat, trainData = train, responseCol = \"class\", nSamples = 50, model = \"mlc\") #> 15:32:07 | Begin sampling training data #> 15:32:07 | Starting to fit model #> 15:32:07 | Starting spatial predict #> ******************** Model summary ******************** #> Maximum Likelihood Classification #> #> 274 samples #> 7 predictor #> 4 classes: 'cleared', 'fallen_dry', 'forest', 'water' #> #> No pre-processing #> Resampling: Cross-Validated (5 fold) #> Summary of sample sizes: 219, 219, 219, 220, 219 #> Resampling results: #> #> Accuracy Kappa #> 1 1 #> #> [[1]] #> TrainAccuracy TrainKappa method #> 1 1 1 custom #> #> [[2]] #> Cross-Validated (5 fold) Confusion Matrix #> #> (entries are average cell counts across resamples) #> #> Reference #> Prediction cleared fallen_dry forest water #> cleared 16.0 0.0 0.0 0.0 #> fallen_dry 0.0 6.8 0.0 0.0 #> forest 0.0 0.0 16.0 0.0 #> water 0.0 0.0 0.0 16.0 #> #> Accuracy (average) : 1 #> #> #> ******************** Validation summary ******************** #> [1] \"No independent validation was performed!\" ## Polish map with majority filter polishedMap <- focal(sc$map, matrix(1,3,3), fun = modal) ## Validation ## Before filtering val0 <- validateMap(sc$map, valData = val, responseCol = \"class\", classMapping = sc$classMapping) ## After filtering val1 <- validateMap(polishedMap, valData = val, responseCol = \"class\", classMapping = sc$classMapping)"},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":null,"dir":"Reference","previous_headings":"","what":"Write ENVI spectral libraries — writeSLI","title":"Write ENVI spectral libraries — writeSLI","text":"Writes binary ENVI spectral library files (sli) accompanying header (.sli.hdr) files ASCII spectral library files ENVI format.","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write ENVI spectral libraries — writeSLI","text":"","code":"writeSLI( x, path, wavl.units = \"Micrometers\", scaleF = 1, mode = \"bin\", endian = .Platform$endian )"},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write ENVI spectral libraries — writeSLI","text":"x data.frame first column containing wavelengths columns containing spectra. path path spectral library file created. wavl.units wavelength units. Defaults Micrometers. Nanometers another typical option. scaleF optional reflectance scaling factor. Defaults 1. mode character string specifying output file type. Must one \"bin\" binary .sli files \"ASCII\" ASCII ENVI plot files. endian character. Optional. default endian determined based platform, can forced manually setting either \"little\" \"big\".","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write ENVI spectral libraries — writeSLI","text":"return anything, write SLI file directly drive specified path parameter","code":""},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Write ENVI spectral libraries — writeSLI","text":"ENVI spectral libraries ending .sli binary arrays spectra saved rows.","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/reference/writeSLI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write ENVI spectral libraries — writeSLI","text":"","code":"## Example data sliFile <- system.file(\"external/vegSpec.sli\", package=\"RStoolbox\") sliTmpFile <- paste0(tempdir(),\"/vegetationSpectra.sli\") ## Read spectral library sli <- readSLI(sliFile) head(sli) #> wavelength veg_stressed veg_vital #> 1 350 0.008958003 0.008836994 #> 2 351 0.008910760 0.008909440 #> 3 352 0.008874181 0.008972186 #> 4 353 0.008847097 0.009025744 #> 5 354 0.008829174 0.009071405 #> 6 355 0.008819440 0.009109739 plot(sli[,1:2], col = \"orange\", type = \"l\") lines(sli[,c(1,3)], col = \"green\") ## Write to binary spectral library writeSLI(sli, path = sliTmpFile)"},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-101","dir":"Changelog","previous_headings":"","what":"RStoolbox 1.0.1","title":"RStoolbox 1.0.1","text":"Changes publication MEE","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-1-0-1","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 1.0.1","text":"spectralIndices() can now customized. made indices available editable option RStoolbox package suggested reviewer. Users now can append custom index calculated via C++ plus within spectralIndices.cpp.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-1-0-1","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 1.0.1","text":"mesma() now throw error anymore given models default value high","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-100","dir":"Changelog","previous_headings":"","what":"RStoolbox 1.0.0","title":"RStoolbox 1.0.0","text":"CRAN release: 2024-04-25 Minor changes major release","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-1-0-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 1.0.0","text":"mesma() now better differentiates SMA MESMA: single endmember unmixing, supplied endmember represents class unmix (row row). multiple endmemeber unmixing, column class can used group endmembers class. multiple endmembers per class provided, mesma() compute number SMA (determined new argument n_models) multiple endmember combinations drawn endmembers select best fit per pixel based lowest RMSE. See ?mesma details (fixes #57, reported @ytarazona)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-1-0-0","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 1.0.0","text":"mesma() now implements sum one constraint default (argument sum_to_one) (fixes #62, reported @michaeldorman) added new example mesma() reflect changes","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-040","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.4.0","title":"RStoolbox 0.4.0","text":"CRAN release: 2024-01-17 Rewrite RStoolbox, migration raster terra sp sf","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-030","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.3.0","title":"RStoolbox 0.3.0","text":"CRAN release: 2022-03-07","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-3-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.3.0","text":"rasterCVA() default longer enforces minimal change magnitude (can still accomplished tmf argument). Also new argument nct allows fix threshold user selected value instead deriving based median observed change magnitudes. unsuperClass() new argument output allows return distances cluster centers raster layers, instead class added spectral index kNDVI spectralIndices() suggested Camps-Valls et al (2021) added support terra::SpatRast objects throughout RStoolbox (alternative raster objects). Note: internal functionality still based raster.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-3-0","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.3.0","text":"arguments master slave coregisterImages() deprecated favor ref img, respectively (closes #63, suggested @MatthiasSiewert)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-3-0","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.3.0","text":"rasterCVA() estimates median values now entire rasters per chunk cloudMask() now returns NA non-clouds instead NaN topCor() now works tiny rasters well (fixes #55, reported @latenooker) rasterPCA() now correctly considers number observations face missing values (fixes #79, reported @andliszmmu) superClass() now accepts different geometries trainData valData (fixes #73, suggested @Silviculturalist) fix readMeta() MTL files delivered Landsat collection data (fixes #71, reported @jkoellin et al.)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-026","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.6","title":"RStoolbox 0.2.6","text":"CRAN release: 2019-07-23","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-6","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.6","text":"red-edge inflection point (REIP), normalized difference red-edge indices (NDREI1, NDREI2), green-band chlorophyll index (CLG), red-edge chlorophyll index (CLRE) Modified Chlorophyll Absorption Ratio Index (MCARI) MERIS Terrestrial Chlorophyll Index (MTCI)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-6","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.6","text":"readSLI() writeSLI() now handle endian binary spectral libraries correctly (#47, fix contributed @aloboa) fix calculation prediction probabilities superClass()(reported Benson Kemboi) adapt raster 2.9.5 API changes fix order thermal calibration coefficients Landsat 8 L1 MTL metadata readMeta (reported Xiaoma Li) fixed issue readSLI() find header files dots pathnames (#51, reported @aloboa)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-6","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.6","text":"modified readSLI label parsing. Internal white space now converted underscores (#52)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-024","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.4","title":"RStoolbox 0.2.4","text":"CRAN release: 2019-01-08","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-4","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.4","text":"function oneHotEncode(): splits single rasterLayer multiple layers (one per class) one-hot encoding, .e. pixel value = 1 matches, pixel value = 0 classes (background). ggR() can now display one layer. layer can plotted subplot multi-panel figure. encodeQA(), decodeQA() classifyQA() can now deal new QA format introduced Landsat Collection data. Legacy QA designations can still interpreted setting legacy argument. new predict() method unsupervised classification models (unsuperClass()).","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-4","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.4","text":"radCor() DOS methods now work Landsat 8 OLI","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-4","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.4","text":"fix unsuperClass() algorithms Hartigan-Wong (reported Alex Ilich)","code":""},{"path":[]},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-2","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.2","text":"added tasseledCap() coefficients Quickbird, Spot5 RapidEye","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-2-2","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.2.2","text":"readEE() ‘Date’ column now returned POSIXct instead POSIXlt","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-2","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.2","text":"corrected tasseledCap() coefficient Landsat 5 TM (#40, reported @philipperufin)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-021","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.1","title":"RStoolbox 0.2.1","text":"CRAN release: 2018-04-09","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-1","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.1","text":"fixed non-portable c++ headers","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-020","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.2.0","title":"RStoolbox 0.2.0","text":"CRAN release: 2018-04-05","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-2-0","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.2.0","text":"function mesma() spectral unmixing (#33, provided Jakob Schwalb-Willmann)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.2.0","text":"improved NA handling faster implementation mlc classifier (#32, pull request Neal Fultz) adapt upcoming caret version (new constraint caret >= 6.0-79)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-0110","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.10","title":"RStoolbox 0.1.10","text":"CRAN release: 2017-11-10","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-10","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.10","text":"fix tests upcoming raster version","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-019","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.9","title":"RStoolbox 0.1.9","text":"CRAN release: 2017-08-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-9","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.9","text":"adapt new caret version fix readEE() new EarthExplorer formats corrected sign greenness tasseledCap() coefficient Landsat5 TM band 1 (reported Thomas Day) adapt readMeta() stackMeta() new Landsat collection 1 metadata","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-018","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.8","title":"RStoolbox 0.1.8","text":"CRAN release: 2017-04-15","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-8","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.8","text":"spectralIndices() can now apply mask internally, e.g. exclude cloud pixels. New arguments : maskLayer maskValue (suggested Andrea Hess). added spectral index GNDWI","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-8","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.8","text":"update readEE() deal new EarthExplorer export columns (reported Christian Bauer)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-017","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.7","title":"RStoolbox 0.1.7","text":"CRAN release: 2017-01-10","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-7","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.7","text":"spectralIndices() new argument skipRefCheck, skips heuristic check reflectance-like values [0,1] run EVI/EVI2 requested. can usefull clouds reflectance > 1.5 part image. superClass() now returns geometries used validation, e.g. polygons (validationvalidationgeometry) also exact samples taken validation including cell number coordinates (validationvalidationvalidationSamples) added example data-set spectral library see ?readSLI increased overall test coverage","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-7","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.7","text":"ESUN lookup tables radCor() adjusted match current USGS recommendations : https://landsat.usgs.gov/esun spectralIndices() swir wavelength ranges now defined consistently correctly. Bands formerly provided swir1 (version <1.7.0) now (>=1.7.0) provided swir2 former swir2 swir3 respectively (see docu). actual calculations correct, naming .","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-7","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.7","text":"fix ggR() ggRGB() annotation mode (default). image drawn excessive memory allocation requested (= RStudio crash) (reported Christian Walther) fix spectralIndices() documentation NDWI. Formula based McFeeters1996 attributed Gao1996. Now NDWI (McFeeters) NDWI2 (Gao) (reported Christian Bauer) estimateHaze() now ensures correct histogram order, raster read disk (reported Xavier Bailleau). readMeta() now makes concise bandnames also Landsat Collection MTL files. fix radCor() Landsat 4 TM (reported Thomas Day) classifyQA() confidence layer type=‘water’ now correctly returns confidence levels [1,3] enable reading ENVI plot files ASCII mode readSLI() Deprecated: * spectralIndices() index LSWI deprecated, identical now available NDWI2.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-016","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.6","title":"RStoolbox 0.1.6","text":"CRAN release: 2016-11-07","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-6","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.6","text":"fix import issue: replace deprecated export caret","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-015","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.5","title":"RStoolbox 0.1.5","text":"CRAN release: 2016-10-06","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-5","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.5","text":"bandSet argument radCor() used process subset bands longer return unprocessed bands along processed bands. Instead processed bands returned. default superClass() now use dataType = ‘INT2S’ classification maps avoid issues raster NA handling INT1U Allow reading importing Landsat MSS MTL files readMeta() stackMeta() (@aszeitz, #7)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-5","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.5","text":"fix readMeta time-stamp conversion now correctly set GMT time (@mraraju, #12) radCor caused R crash bandSet single band fix single RasterLayer capability superClass spectralIndices now calculates documented indices specified (@mej1d1, #6) unsuperClass predicted map now handles NAs properly pifMatch return adjusted image (@tmb3006, #13) Deprecated: * argument norm dropped rasterPCA, effectively duplicate standardized pca (spca) argument function.","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-014","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.4","title":"RStoolbox 0.1.4","text":"CRAN release: 2016-01-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-4","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.4","text":"new function validateMap() assessing map accuracy separately model fitting, e.g. majority MMU filtering new function getValidation() extract specific validation results superClass objects (proposed James Duffy) new spectral index NDVIc (proposed Jeff Evans) new argument scaleFactor spectralIndices() calculation EVI/EVI2 based scaled reflectance values. implemented dark object subtraction radCor(..,method=‘sdos’) Landsat 8 data (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"changes-0-1-4","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.1.4","text":"superClass based polygons now considers pixels center coordinate within polygon rasterCVA now returns angles 0 360° instead 0:45 quadrant (reported Martin Wegmann) improved dark object DN estimation based maximum slope histogram estimateHaze() (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-4","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.4","text":"superClass failed neither valData trainPartition specified. regression introduced 0.1.3 (reported Anna Stephani) spectralIndices valid value range EVI/EVI2 now [-1,1] radCor returned smallest integer instead NA NA pixels fix ‘sdos’ non-contiguous bands radCor (@BayAludra, #4)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-013","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.3","title":"RStoolbox 0.1.3","text":"CRAN release: 2015-11-28","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-3","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.3","text":"new logical argument predict() superClass. Disables prediction full raster (validation still conducted). new generic predict() function superClass objects. Useful separate model training prediction. new example data set (landcover training polygons) lsat example data /extdata/trainingPolygons.rds","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-3","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.3","text":"fix histMatch single layers (affected also ‘ihs’ pan-sharpening) fix superClass validation sampling factors (character based factors lead wrong factor conversions wrong validation results) improved handling training polygons overlaps shared borders superClass improved checks error messages insufficient training polygons","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-012","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.2","title":"RStoolbox 0.1.2","text":"CRAN release: 2015-11-04","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-1-2","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.1.2","text":"New model superClass: maximum likelihood classification (model = “mlc”)","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"fixes-0-1-2","dir":"Changelog","previous_headings":"","what":"Fixes:","title":"RStoolbox 0.1.2","text":"Restrict calculation EVI/EVI2 reflectance data (#3) Enforce valid value ranges radCor(): radiance: [0,+Inf], reflectance: [0,1]. Includes new argument clamp turn (default).","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-011","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.1","title":"RStoolbox 0.1.1","text":"CRAN release: 2015-09-08 Added kernlab suggested packages able test examples","code":""},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"rstoolbox-010","dir":"Changelog","previous_headings":"","what":"RStoolbox 0.1.0","title":"RStoolbox 0.1.0","text":"CRAN release: 2015-09-05 Initial release CRAN (2015-09-05) following functions: * classifyQA() * cloudMask() * cloudShadowMask() * coregisterImages() * decodeQA() * encodeQA() * estimateHaze() * fortify.raster() * fCover() * getMeta() * ggR() * ggRGB() * histMatch() * ImageMetaData() * normImage() * panSharpen() * pifMatch() * radCor() * rasterCVA() * rasterEntropy() * rasterPCA() * readEE() * readMeta() * readRSTBX() * readSLI() * rescaleImage() * rsOpts() * sam() * saveRSTBX() * spectralIndices() * stackMeta() * superClass() * tasseledCap() * topCor() * unsuperClass() * writeSLI() Included example data sets: * data(srtm) * data(lsat) * data(rlogo)","code":""}]
SRTM Digital Elevation Model
- Source:R/RStoolbox-package.R
+ Source: R/RStoolbox-package.R
srtm.Rd
SRTM scene for the sen2 exemplary scene
- Source:R/RStoolbox-package.R
+ Source: R/RStoolbox-package.R
srtm_sen2.Rd
Import separate Landsat files into single stack
- Source:R/stackMeta.R
+ Source: R/stackMeta.R
stackMeta.Rd