instance trees (trac-13180)
+ cur.nodeType &&
+
+ // Support: Firefox <=42
+ // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
+ // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
+ // Support: IE 11 only
+ // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
+ !( event.type === "click" && event.button >= 1 ) ) {
+
+ for ( ; cur !== this; cur = cur.parentNode || this ) {
+
+ // Don't check non-elements (#13208)
+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
+ matchedHandlers = [];
+ matchedSelectors = {};
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
+
+ if ( matchedSelectors[ sel ] === undefined ) {
+ matchedSelectors[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) > -1 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( matchedSelectors[ sel ] ) {
+ matchedHandlers.push( handleObj );
+ }
+ }
+ if ( matchedHandlers.length ) {
+ handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ cur = this;
+ if ( delegateCount < handlers.length ) {
+ handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
+ }
+
+ return handlerQueue;
+ },
+
+ addProp: function( name, hook ) {
+ Object.defineProperty( jQuery.Event.prototype, name, {
+ enumerable: true,
+ configurable: true,
+
+ get: isFunction( hook ) ?
+ function() {
+ if ( this.originalEvent ) {
+ return hook( this.originalEvent );
+ }
+ } :
+ function() {
+ if ( this.originalEvent ) {
+ return this.originalEvent[ name ];
+ }
+ },
+
+ set: function( value ) {
+ Object.defineProperty( this, name, {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: value
+ } );
+ }
+ } );
+ },
+
+ fix: function( originalEvent ) {
+ return originalEvent[ jQuery.expando ] ?
+ originalEvent :
+ new jQuery.Event( originalEvent );
+ },
+
+ special: {
+ load: {
+
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+ click: {
+
+ // Utilize native event to ensure correct state for checkable inputs
+ setup: function( data ) {
+
+ // For mutual compressibility with _default, replace `this` access with a local var.
+ // `|| data` is dead code meant only to preserve the variable through minification.
+ var el = this || data;
+
+ // Claim the first handler
+ if ( rcheckableType.test( el.type ) &&
+ el.click && nodeName( el, "input" ) ) {
+
+ // dataPriv.set( el, "click", ... )
+ leverageNative( el, "click", returnTrue );
+ }
+
+ // Return false to allow normal processing in the caller
+ return false;
+ },
+ trigger: function( data ) {
+
+ // For mutual compressibility with _default, replace `this` access with a local var.
+ // `|| data` is dead code meant only to preserve the variable through minification.
+ var el = this || data;
+
+ // Force setup before triggering a click
+ if ( rcheckableType.test( el.type ) &&
+ el.click && nodeName( el, "input" ) ) {
+
+ leverageNative( el, "click" );
+ }
+
+ // Return non-false to allow normal event-path propagation
+ return true;
+ },
+
+ // For cross-browser consistency, suppress native .click() on links
+ // Also prevent it if we're currently inside a leveraged native-event stack
+ _default: function( event ) {
+ var target = event.target;
+ return rcheckableType.test( target.type ) &&
+ target.click && nodeName( target, "input" ) &&
+ dataPriv.get( target, "click" ) ||
+ nodeName( target, "a" );
+ }
+ },
+
+ beforeunload: {
+ postDispatch: function( event ) {
+
+ // Support: Firefox 20+
+ // Firefox doesn't alert if the returnValue field is not set.
+ if ( event.result !== undefined && event.originalEvent ) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ }
+};
+
+// Ensure the presence of an event listener that handles manually-triggered
+// synthetic events by interrupting progress until reinvoked in response to
+// *native* events that it fires directly, ensuring that state changes have
+// already occurred before other listeners are invoked.
+function leverageNative( el, type, expectSync ) {
+
+ // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
+ if ( !expectSync ) {
+ if ( dataPriv.get( el, type ) === undefined ) {
+ jQuery.event.add( el, type, returnTrue );
+ }
+ return;
+ }
+
+ // Register the controller as a special universal handler for all event namespaces
+ dataPriv.set( el, type, false );
+ jQuery.event.add( el, type, {
+ namespace: false,
+ handler: function( event ) {
+ var notAsync, result,
+ saved = dataPriv.get( this, type );
+
+ if ( ( event.isTrigger & 1 ) && this[ type ] ) {
+
+ // Interrupt processing of the outer synthetic .trigger()ed event
+ // Saved data should be false in such cases, but might be a leftover capture object
+ // from an async native handler (gh-4350)
+ if ( !saved.length ) {
+
+ // Store arguments for use when handling the inner native event
+ // There will always be at least one argument (an event object), so this array
+ // will not be confused with a leftover capture object.
+ saved = slice.call( arguments );
+ dataPriv.set( this, type, saved );
+
+ // Trigger the native event and capture its result
+ // Support: IE <=9 - 11+
+ // focus() and blur() are asynchronous
+ notAsync = expectSync( this, type );
+ this[ type ]();
+ result = dataPriv.get( this, type );
+ if ( saved !== result || notAsync ) {
+ dataPriv.set( this, type, false );
+ } else {
+ result = {};
+ }
+ if ( saved !== result ) {
+
+ // Cancel the outer synthetic event
+ event.stopImmediatePropagation();
+ event.preventDefault();
+
+ // Support: Chrome 86+
+ // In Chrome, if an element having a focusout handler is blurred by
+ // clicking outside of it, it invokes the handler synchronously. If
+ // that handler calls `.remove()` on the element, the data is cleared,
+ // leaving `result` undefined. We need to guard against this.
+ return result && result.value;
+ }
+
+ // If this is an inner synthetic event for an event with a bubbling surrogate
+ // (focus or blur), assume that the surrogate already propagated from triggering the
+ // native event and prevent that from happening again here.
+ // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
+ // bubbling surrogate propagates *after* the non-bubbling base), but that seems
+ // less bad than duplication.
+ } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
+ event.stopPropagation();
+ }
+
+ // If this is a native event triggered above, everything is now in order
+ // Fire an inner synthetic event with the original arguments
+ } else if ( saved.length ) {
+
+ // ...and capture the result
+ dataPriv.set( this, type, {
+ value: jQuery.event.trigger(
+
+ // Support: IE <=9 - 11+
+ // Extend with the prototype to reset the above stopImmediatePropagation()
+ jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
+ saved.slice( 1 ),
+ this
+ )
+ } );
+
+ // Abort handling of the native event
+ event.stopImmediatePropagation();
+ }
+ }
+ } );
+}
+
+jQuery.removeEvent = function( elem, type, handle ) {
+
+ // This "if" is needed for plain objects
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle );
+ }
+};
+
+jQuery.Event = function( src, props ) {
+
+ // Allow instantiation without the 'new' keyword
+ if ( !( this instanceof jQuery.Event ) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = src.defaultPrevented ||
+ src.defaultPrevented === undefined &&
+
+ // Support: Android <=2.3 only
+ src.returnValue === false ?
+ returnTrue :
+ returnFalse;
+
+ // Create target properties
+ // Support: Safari <=6 - 7 only
+ // Target should not be a text node (#504, #13143)
+ this.target = ( src.target && src.target.nodeType === 3 ) ?
+ src.target.parentNode :
+ src.target;
+
+ this.currentTarget = src.currentTarget;
+ this.relatedTarget = src.relatedTarget;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || Date.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ constructor: jQuery.Event,
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+ isSimulated: false,
+
+ preventDefault: function() {
+ var e = this.originalEvent;
+
+ this.isDefaultPrevented = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.preventDefault();
+ }
+ },
+ stopPropagation: function() {
+ var e = this.originalEvent;
+
+ this.isPropagationStopped = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.stopPropagation();
+ }
+ },
+ stopImmediatePropagation: function() {
+ var e = this.originalEvent;
+
+ this.isImmediatePropagationStopped = returnTrue;
+
+ if ( e && !this.isSimulated ) {
+ e.stopImmediatePropagation();
+ }
+
+ this.stopPropagation();
+ }
+};
+
+// Includes all common event props including KeyEvent and MouseEvent specific props
+jQuery.each( {
+ altKey: true,
+ bubbles: true,
+ cancelable: true,
+ changedTouches: true,
+ ctrlKey: true,
+ detail: true,
+ eventPhase: true,
+ metaKey: true,
+ pageX: true,
+ pageY: true,
+ shiftKey: true,
+ view: true,
+ "char": true,
+ code: true,
+ charCode: true,
+ key: true,
+ keyCode: true,
+ button: true,
+ buttons: true,
+ clientX: true,
+ clientY: true,
+ offsetX: true,
+ offsetY: true,
+ pointerId: true,
+ pointerType: true,
+ screenX: true,
+ screenY: true,
+ targetTouches: true,
+ toElement: true,
+ touches: true,
+ which: true
+}, jQuery.event.addProp );
+
+jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
+ jQuery.event.special[ type ] = {
+
+ // Utilize native event if possible so blur/focus sequence is correct
+ setup: function() {
+
+ // Claim the first handler
+ // dataPriv.set( this, "focus", ... )
+ // dataPriv.set( this, "blur", ... )
+ leverageNative( this, type, expectSync );
+
+ // Return false to allow normal processing in the caller
+ return false;
+ },
+ trigger: function() {
+
+ // Force setup before trigger
+ leverageNative( this, type );
+
+ // Return non-false to allow normal event-path propagation
+ return true;
+ },
+
+ // Suppress native focus or blur as it's already being fired
+ // in leverageNative.
+ _default: function() {
+ return true;
+ },
+
+ delegateType: delegateType
+ };
+} );
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+// so that event delegation works in jQuery.
+// Do the same for pointerenter/pointerleave and pointerover/pointerout
+//
+// Support: Safari 7 only
+// Safari sends mouseenter too often; see:
+// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
+// for the description of the bug (it existed in older Chrome versions as well).
+jQuery.each( {
+ mouseenter: "mouseover",
+ mouseleave: "mouseout",
+ pointerenter: "pointerover",
+ pointerleave: "pointerout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj;
+
+ // For mouseenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+} );
+
+jQuery.fn.extend( {
+
+ on: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn );
+ },
+ one: function( types, selector, data, fn ) {
+ return on( this, types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ?
+ handleObj.origType + "." + handleObj.namespace :
+ handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each( function() {
+ jQuery.event.remove( this, types, fn, selector );
+ } );
+ }
+} );
+
+
+var
+
+ // Support: IE <=10 - 11, Edge 12 - 13 only
+ // In IE/Edge using regex groups here causes severe slowdowns.
+ // See https://connect.microsoft.com/IE/feedback/details/1736512/
+ rnoInnerhtml = /
-
-
-
-
-
-
-
-
-
-
encodeQA {RStoolbox} R Documentation
-
-
Encode QA Conditions to Integers
-
-
Description
-
-
Intended for use with Landsat 16-bit QA bands. Converts pixel quality flags from human readable to integer, which can then be used to
-subset a QA image. Please be aware of the default settings which differ for different parameters.
-Depending on, which sensor
and legacy
is selected, some quality parameters are not used, since the sequences of available bitwise quality designations differ per sensor and collection.
-
-
-
-
Usage
-
-
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"
-)
-
-
-
-
Arguments
-
-
-fill
-
-Designated fill. Options: c("yes", "no", "all")
.
-
-terrainOcclusion
-
-Terrain induced occlusion. Options: c("yes", "no", "all")
.
-
-radSaturation
-
-Number of bands that contain radiometric saturation. Options: c("na", "low", "med", "high", "all")
for no bands, 1-2 bands, 3-4 bands, 5 or more bands contain saturation.
-
-cloudMask
-
-Cloud mask. Options: c("yes", "no", "all")
.
-
-cloud
-
-Cloud confidence. Options: c("na", "low", "med", "high", "all")
.
-
-cloudShadow
-
-Cloud shadow confidence. Options: c("yes", "no", "all")
.
-
-snow
-
-Snow / ice confidence. Options: c("na", "low", "med", "high", "all")
.
-
-cirrus
-
-Cirrus confidence. Options: c("na", "low", "med", "high", "all")
.
-
-droppedPixel
-
-Dropped pixel. Options: c("yes", "no", "all")
.
-
-water
-
-Water confidence. Options: c("na", "low", "med", "high", "all")
.
-
-droppedFrame
-
-Dropped frame. Options: c("yes", "no", "all")
.
-
-sensor
-
-Sensor to encode. Options: c("OLI", "TIRS", "ETM+", "TM", "MSS")
.
-
-legacy
-
-Encoding systematic Options: c("collection1", "pre_collection")
. Default is "collection1" for the Landsat Collection 1 8-bit quality designations. Use "pre_collection" for imagery downloaded before the Collection 1 quality designations were introduced
-
-
-
-
-
Value
-
-
Returns the Integer value for the QA values
-
-
-
-
Note
-
-
Only currently populated bits are available as arguments.
-
-
-
-
References
-
-
https://www.usgs.gov/landsat-missions/landsat-collection-1-level-1-quality-assessment-band for Collection 1 quality designations (legacy = "collection1"
)
-
-
-
-
Examples
-
-
encodeQA(snow = "low", cirrus = c("med", "high"), cloud = "high")
-
-
## [1] 23136 23264 23392 23520 23152 23280 23408 23536
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/estimateHaze.html b/estimateHaze.html
deleted file mode 100644
index 8e9ded1..0000000
--- a/estimateHaze.html
+++ /dev/null
@@ -1,118 +0,0 @@
-R: Estimate Image Haze for Dark Object Subtraction (DOS)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
estimateHaze {RStoolbox} R Documentation
-
-
Estimate Image Haze for Dark Object Subtraction (DOS)
-
-
Description
-
-
estimates the digital number (DN) pixel value of *dark* objects for the visible wavelength range.
-
-
-
-
Usage
-
-
estimateHaze(
- x,
- hazeBands,
- darkProp = 0.01,
- maxSlope = TRUE,
- plot = FALSE,
- returnTables = FALSE
-)
-
-
-
-
Arguments
-
-
-x
-
-RasterLayer or SpatRaster or a previous result from estimateHaze
with returnTables = TRUE
from which to estimate haze
-
-hazeBands
-
-Integer or Character. Band number or bandname from which to estimate atmospheric haze (optional if x contains only one layer)
-
-darkProp
-
-Numeric. Proportion of pixels estimated to be dark.
-
-maxSlope
-
-Logical. Use darkProp
only as an upper boundary and search for the DN of maximum slope in the histogram below this value.
-
-plot
-
-Logical. Option to display histograms and haze values
-
-returnTables
-
-Logical. Option to return the frequency table per layer. Only takes effect if x is a SpatRaster. If x is a result of estimateHaze tables will always be returned.
-
-
-
-
-
Details
-
-
It is assumed that any radiation originating from *dark* pixels is due to atmospheric haze and
-not the reflectance of the surface itself (the surface is dark, i.e. it has a reflectance close to zero).
-Hence, the haze values are estimates of path radiance, which can be subtracted in a dark object subtraction (DOS) procedure (see radCor
)
-
-
Atmospheric haze affects almost exclusively the visible wavelength range. Therefore, typically, you'd only want to estimate haze in blue, green and red bands, occasionally also in the nir band.
-
-
-
-
Value
-
-
If returnTables is FALSE (default). Then a vector of length(hazeBands) containing the estimated haze DNs will be returned.
-If returnTables is TRUE a list with two components will be returned. The list element 'SHV' contains the haze values, while 'table'
-contains another list with the sampled frequency tables. The latter can be re-used to try different darkProp thresholds without having to sample
-the raster again.
-
-
-
-
Examples
-
-
## 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
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/fCover.html b/fCover.html
deleted file mode 100644
index 1e0bdc5..0000000
--- a/fCover.html
+++ /dev/null
@@ -1,216 +0,0 @@
-R: Fractional Cover Analysis
-
-
-
-
-
-
-
-
-
-
-
-
-
-
fCover {RStoolbox} R Documentation
-
-
Fractional Cover Analysis
-
-
Description
-
-
fCover takes a classified high resolution image, e.g. vegetation and non-vegetation based on Landsat and calculates cover fractions for
-pixels of a coarser resolution, e.g. MODIS.
-
-
-
-
Usage
-
-
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,
- ...
-)
-
-
-
-
Arguments
-
-
-classImage
-
-high resolution RasterLayer or SpatRaster containing a landcover classification, e.g. as obtained by superClass .
-
-predImage
-
-coarse resolution RasterLayer or SpatRaster for which fractional cover will be estimated.
-
-nSamples
-
-Integer. Number of pixels to sample from predImage to train the regression model
-
-classes
-
-Integer. Classes for which fractional cover should be estimated (one or more).
-
-maxNA
-
-Numeric. Maximal proportion of NAs allowed in training pixels.
-
-clamp
-
-Logical. Enforce results to stay within [0,1] interval. Values <0 are reset to 0 and values >1 to 1.
-
-model
-
-Character. Which model to fit for image regression. See train for options. Defaults to randomForest ('rf')
-
-tuneLength
-
-Integer. Number of levels for each tuning parameters that should be generated by train. See Details and train
.
-
-trControl
-
-trainControl
object, specifying resampling, validation etc.
-
-method
-
-DEPREACTED! in favor of trControl=trainControl(method="cv")
Resampling method for parameter tuning. Defaults to 10 fold cross-validation. See trainControl
for options.
-
-filename
-
-Character. Filename of the output raster file (optional).
-
-overwrite
-
-Logical. if TRUE
, filename
will be overwritten.
-
-verbose
-
-Logical. Print progress information.
-
-...
-
-further arguments to be passed to writeRaster
-
-
-
-
-
Details
-
-
fCover gets the pixel values in a high resolution classified image that correspond to
-randomly selected moderate resolution pixels and then calculates the percent of
-the classified image pixels that represent your cover type of interest. In other words, if
-your high resolution image has a pixel size of 1m and your moderate resolution image has a
-pixel size of 30m the sampling process would take a block of 900 of the 1m resolution pixels
-that correspond to a single 30m pixel and calculate the percentage of the 1m pixels that
-are forest. For example, if there were 600 forest pixels and 300 non-forest pixels the value
-given for the output pixel would be 0.67 since 67
-
-
fCover relies on the train() function from the caret package which provides access to a huge number of classifiers.
-Please see the available options at train . The default classifier (randomForest) we chose has been shown
-to provide very good results in image regression and hence it is recomended you start with this one. If you choose a different
-classifier, make sure it can run in regression mode.
-
-
Many models require tuning of certain parameters. Again, this is handled by train from the caret package.
-With the tuneLength argument you can specify how many different values of each tuning parameter should be tested. The Random Forest
-algorithm for example can be tuned by varying the mtry parameter. Hence, by specifying tuneLength = 10, ten different levels
-of mtry will be tested in a cross-validation scheme and the best-performing value will be chosen for the final model.
-
-
If the total no-data values for a block of high resolution pixels is greater than maxNA then
-it will not be included in the training data set since there is too much missing data to provide
-a reliable cover percentage. If the no-data proporton is less then maxNA the no-data pixels are removed
-from the total number of pixels when calculating the percent cover.
-
-
-
-
Value
-
-
Returns a list with two elements: models contains the fitted models evaluated in tenfold cross-validation (caret train objects);
-fCover contains a SpatRaster with a fractional cover layer for each requested class.
-
-
-
-
See Also
-
-
superClass
-
-
-
-
Examples
-
-
## No test:
-library(terra)
-library(caret)
-
-
## Loading required package: lattice
-
-
## Warning: package 'lattice' was built under R version 4.2.3
-
-
## 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))
-## End(No test)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/favicon-16x16.png b/favicon-16x16.png
new file mode 100644
index 0000000..7a26ea4
Binary files /dev/null and b/favicon-16x16.png differ
diff --git a/favicon-32x32.png b/favicon-32x32.png
new file mode 100644
index 0000000..431b80c
Binary files /dev/null and b/favicon-32x32.png differ
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000..7818346
Binary files /dev/null and b/favicon.ico differ
diff --git a/files/DESCRIPTION b/files/DESCRIPTION
deleted file mode 100644
index 3ecc5df..0000000
--- a/files/DESCRIPTION
+++ /dev/null
@@ -1,45 +0,0 @@
-Package: RStoolbox
-Type: Package
-Title: Remote Sensing Data Analysis
-Version: 0.4.0
-Authors@R: c(
- person("Benjamin", "Leutner", role=c("aut"), email="rstoolboxpackage@gmail.com", comment = c(ORCID = "0000-0002-6893-2002")),
- person("Ned", "Horning", role ="aut", email="horning@amnh.org"),
- person("Jakob", "Schwalb-Willmann", role ="aut", email="movevis@schwalb-willmann.de", comment = c(ORCID = "0000-0003-2665-1509")),
- person("Robert J.", "Hijmans", role = "ctb", email = "r.hijmans@gmail.com",comment = c(ORCID = "0000-0001-5872-2872")),
- person("Konstantin", "Mueller", role = c("aut", "cre"), email = "konstantinfinn.mueller@gmx.de", comment = c(ORCID = "0000-0001-6540-3124"))
- )
-Description: Toolbox for remote sensing image processing and analysis such as
- calculating spectral indexes, principal component transformation, unsupervised
- and supervised classification or fractional cover analyses.
-URL: https://bleutner.github.io/RStoolbox/, https://github.com/bleutner/RStoolbox
-BugReports: https://github.com/bleutner/RStoolbox/issues
-Encoding: UTF-8
-Depends:
- R (>= 3.5.0)
-Imports:
- caret (>= 6.0-79),
- sf,
- terra (>= 1.6-41),
- XML,
- dplyr,
- ggplot2,
- tidyr,
- reshape2,
- lifecycle,
- exactextractr,
- Rcpp,
- methods,
- magrittr
-Suggests:
- randomForest,
- kernlab,
- e1071,
- gridExtra,
- pls,
- testthat
-LinkingTo: Rcpp,
- RcppArmadillo
-License: GPL (>=3)
-RoxygenNote: 7.2.3
-LazyData: true
diff --git a/fortifySpatRaster.html b/fortifySpatRaster.html
deleted file mode 100644
index 933a861..0000000
--- a/fortifySpatRaster.html
+++ /dev/null
@@ -1,75 +0,0 @@
-R: Fortify method for classes from the terra package.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
fortifySpatRaster {RStoolbox} R Documentation
-
-
Fortify method for classes from the terra package.
-
-
Description
-
-
Fortify method for classes from the terra package.
-
-
-
-
Usage
-
-
fortifySpatRaster(x, maxpixels = 50000)
-
-
-
-
Arguments
-
-
-x
-
-SpatRaster
object to convert into a dataframe.
-
-maxpixels
-
-Integer. Maximum number of pixels to sample
-
-
-
-
-
Value
-
-
Returns a data.frame with coordinates (x,y) and corresponding raster values.
-
-
-
-
Examples
-
-
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
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/getMeta.html b/getMeta.html
deleted file mode 100644
index de245d9..0000000
--- a/getMeta.html
+++ /dev/null
@@ -1,186 +0,0 @@
-R: Extract bandwise information from ImageMetaData
-
-
-
-
-
-
-
-
-
-
-
-
-
-
getMeta {RStoolbox} R Documentation
-
-
Extract bandwise information from ImageMetaData
-
-
Description
-
-
This is an accessor function to quickly access information stored in ImageMetaData, e.g. scale factor per band.
-Intended for use with imagery which was imported using stackMeta. Will return parameters using the actual band order in img.
-
-
-
-
Usage
-
-
getMeta(img, metaData, what)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster or character vector with band names.
-
-metaData
-
-ImageMetaData or path to meta data file.
-
-what
-
-Character. Parameter to extract. Either data descriptors, or conversion parameters (see Details for options)
-
-
-
-
-
Details
-
-
Possible metadata parameters (what
argument):
-
-
Data descriptors
-
-
-
-
-
-'FILES'
-
-
-
-'QUANTITY'
-
-
-
-'CATEGORY'
-
-
-
-'NA_VALUE'
-
-
-
-'SATURATE_VALUE'
-
-
-
-'SCALE_FACTOR'
-
-
-
-'DATA_TYPE'
-
-
-
-'SPATIAL_RESOLUTION'
-
-
-
-
-
-
-
-
-
Conversion parameters
-
-
-
-
-
-'CALRAD' Conversion parameters from DN to radiance
-
-
-
-'CALBT' Conversion parameters from radiance to brightness temperature
-
-
-
-'CALREF' Conversion parameters from DN to reflectance (Landsat 8 only)
-
-
-
-
-
-
-
-
-
-
-
Value
-
-
If what
is one of c('CALRAD', 'CALBT', 'CALREF')
a data.frame is returned with bands in rows (order corresponding to img
band order).
-Otherwise a named numeric vector with the corresponding parameter is returned (layernames as names).
-
-
-
-
Examples
-
-
## 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 B3_dn
-## "LT52240631988227CUB02_B1.TIF" "LT52240631988227CUB02_B2.TIF" "LT52240631988227CUB02_B3.TIF"
-## B4_dn B5_dn B6_dn
-## "LT52240631988227CUB02_B4.TIF" "LT52240631988227CUB02_B5.TIF" "LT52240631988227CUB02_B6.TIF"
-## B7_dn
-## "LT52240631988227CUB02_B7.TIF"
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/getValidation.html b/getValidation.html
deleted file mode 100644
index db3f403..0000000
--- a/getValidation.html
+++ /dev/null
@@ -1,113 +0,0 @@
-R: Extract validation results from superClass objects
-
-
-
-
-
-
-
-
-
-
-
-
-
-
getValidation {RStoolbox} R Documentation
-
-
Extract validation results from superClass objects
-
-
Description
-
-
Extract validation results from superClass objects
-
-
-
-
Usage
-
-
getValidation(x, from = "testset", metrics = "overall")
-
-
-
-
Arguments
-
-
-x
-
-superClass object or caret::confusionMatrix
-
-from
-
-Character. 'testset' extracts the results from independent validation with testset. 'cv' extracts cross-validation results.
-
-metrics
-
-Character. Only relevant in classification mode (ignored for regression models).
-Select 'overall' for overall accuracy metrics, 'classwise' for classwise metrics,
-'confmat' for the confusion matrix itself and 'caret' to return the whole caret::confusionMatrix object.
-
-
-
-
-
Value
-
-
Returns a data.frame with validation results.
-If metrics = 'confmat' or 'caret' will return a table or the full caret::confusionMatrix object, respectively.
-
-
-
-
Examples
-
-
library(pls)
-
-
## Warning: package 'pls' was built under R version 4.2.3
-
-
##
-## 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.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 AccuracyPValue McnemarPValue
-## 1 pls testset 0.7777778 0.6666667 0.3999064 0.971855 0.3333333 0.008281258 NaN
-
-
getValidation(SC, metrics = "classwise")
-
-
## model validation class Sensitivity Specificity Pos.Pred.Value Neg.Pred.Value Precision Recall F1
-## 1 pls testset A 1.0000000 0.6666667 0.6 1.00 0.6 1.0000000 0.75
-## 2 pls testset B 0.3333333 1.0000000 1.0 0.75 1.0 0.3333333 0.50
-## 3 pls testset C 1.0000000 1.0000000 1.0 1.00 1.0 1.0000000 1.00
-## Prevalence Detection.Rate Detection.Prevalence Balanced.Accuracy
-## 1 0.3333333 0.3333333 0.5555556 0.8333333
-## 2 0.3333333 0.1111111 0.1111111 0.6666667
-## 3 0.3333333 0.3333333 0.3333333 1.0000000
-
-
## Cross-validation based
-getValidation(SC, from = "cv")
-
-
## model validation Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull AccuracyPValue McnemarPValue
-## 1 pls cv 0.9047619 0.8571429 0.6962256 0.9882507 0.3333333 8.441398e-08 NaN
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/ggR.html b/ggR.html
deleted file mode 100644
index 8af3b1a..0000000
--- a/ggR.html
+++ /dev/null
@@ -1,238 +0,0 @@
-R: Plot RasterLayers in ggplot with greyscale
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ggR {RStoolbox} R Documentation
-
-
Plot RasterLayers in ggplot with greyscale
-
-
Description
-
-
Plot single layer imagery in grey-scale. Can be used with a SpatRaster.
-
-
-
-
Usage
-
-
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
-)
-
-
-
-
Arguments
-
-
-img
-
-raster
-
-layer
-
-Character or numeric. Layername or number. Can be more than one layer, in which case each layer is plotted in a subplot.
-
-maxpixels
-
-Integer. Maximal number of pixels to sample.
-
-alpha
-
-Numeric. Transparency (0-1).
-
-hue
-
-Numeric. Hue value for color calculation [0,1] (see hsv
). Change if you need anything else than greyscale. Only effective if sat > 0
.
-
-sat
-
-Numeric. Saturation value for color calculation [0,1] (see hsv
). Change if you need anything else than greyscale.
-
-stretch
-
-Character. Either 'none', 'lin', 'hist', 'sqrt' or 'log' for no stretch, linear, histogram, square-root or logarithmic stretch.
-
-quantiles
-
-Numeric vector with two elements. Min and max quantiles to stretch to. Defaults to 2% stretch, i.e. c(0.02,0.98).
-
-ext
-
-Extent object to crop the image
-
-coord_equal
-
-Logical. Force addition of coord_equal, i.e. aspect ratio of 1:1. Typically useful for remote sensing data (depending on your projection), hence it defaults to TRUE.
-Note however, that this does not apply if (ggLayer=FALSE
).
-
-ggLayer
-
-Logical. Return only a ggplot layer which must be added to an existing ggplot. If FALSE
s stand-alone ggplot will be returned.
-
-ggObj
-
-Logical. Return a stand-alone ggplot object (TRUE) or just the data.frame with values and colors
-
-geom_raster
-
-Logical. If FALSE
uses annotation_raster (good to keep aestetic mappings free). If TRUE
uses geom_raster
(and aes(fill)
). See Details.
-
-forceCat
-
-Logical. If TRUE
the raster values will be forced to be categorical (will be converted to factor if needed).
-
-
-
-
-
Details
-
-
When img
contains factor values and annotation=TRUE
, the raster values will automatically be converted
-to numeric in order to proceed with the brightness calculation.
-
-
The geom_raster argument switches from the default use of annotation_raster to geom_raster. The difference between the two is that geom_raster performs
-a meaningful mapping from pixel values to fill colour, while annotation_raster is simply adding a picture to your plot. In practice this means that whenever you
-need a legend for your raster you should use geom_raster = TRUE
. This also allows you to specify and modify the fill scale manually.
-The advantage of using annotation_raster (geom_raster = TRUE
) is that you can still use the scale_fill* for another variable. For example you could add polygons and
-map a value to their fill colour. For more details on the theory behind aestetic mapping have a look at the ggplot2 manuals.
-
-
-
-
Value
-
-
-
-
-
- ggObj = TRUE
: ggplot2 plot
-
-
-
- ggLayer = TRUE
: ggplot2 layer to be combined with an existing ggplot2
-
-
-
- ggObj = FALSE
: data.frame in long format suitable for plotting with ggplot2,
- includes the pixel values and the calculated colors
-
-
-
-
-
-
-
-
-
-
-
See Also
-
-
ggRGB , fortifySpatRaster
-
-
-
-
Examples
-
-
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
-## No test:
-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))
-
-
-
## End(No test)
-## 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")
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/ggRGB.html b/ggRGB.html
deleted file mode 100644
index 119fe33..0000000
--- a/ggRGB.html
+++ /dev/null
@@ -1,217 +0,0 @@
-R: Create ggplot2 Raster Plots with RGB from 3 RasterLayers
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ggRGB {RStoolbox} R Documentation
-
-
Create ggplot2 Raster Plots with RGB from 3 RasterLayers
-
-
Description
-
-
Calculates RGB color composite raster for plotting with ggplot2. Optional values for clipping and and stretching can be used to enhance the imagery.
-
-
-
-
Usage
-
-
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
-)
-
-
-
-
Arguments
-
-
-img
-
-RasterStack or RasterBrick
-
-r
-
-Integer or character. Red layer in x. Can be set to NULL
, in which case the red channel will be set to zero.
-
-g
-
-Integer or character. Green layer in x. Can be set to NULL
, in which case the green channel will be set to zero.
-
-b
-
-Integer or character. Blue layer in x. Can be set to NULL
, in which case the blue channel will be set to zero.
-
-scale
-
-Numeric. Maximum possible pixel value (optional). Defaults to 255 or to the maximum value of x if that is larger than 255
-
-maxpixels
-
-Integer. Maximal number of pixels used for plotting.
-
-stretch
-
-Character. Either 'none', 'lin', 'hist', 'sqrt' or 'log' for no stretch, linear, histogram, square-root or logarithmic stretch.
-
-ext
-
-Extent or SpatExtent object to crop the image
-
-limits
-
-Vector or matrix. Can be used to reduce the range of values. Either a vector of two values for all bands (c(min, max))
-or a 3x2 matrix with min and max values (columns) for each layer (rows).
-
-clipValues
-
-Matrix, numeric vector, string or NA. Values to reset out of range (out of limits
) values to.
-By default ('limits') values are reset to limits
. A single value (e.g. NA) will be recycled to all lower/higher clippings,
-A vector of length two (c(min,max)) can be used to specify lower and higher replace values, applied to all bands.
-A two column matrix (typically with three rows) can be used to fully control lower and upper clipping values differently for each band.
-
-quantiles
-
-Numeric vector with two elements. Min and max quantiles to stretch. Defaults to 2% stretch, i.e. c(0.02,0.98).
-
-ggObj
-
-Logical. If TRUE
a ggplot2 object is returned. If FALSE
a data.frame with coordinates and color will be returned.
-
-ggLayer
-
-Logical. If TRUE
a ggplot2 layer is returned. This is useful if you want to add it to an existing ggplot2 object.
-Note that if TRUE
& annotate = FALSE
you have to add a scale_fill_identity() manually in your call to ggplot().
-
-alpha
-
-Numeric. Transparency (0-1).
-
-coord_equal
-
-Logical. Force addition of coord_equal, i.e. aspect ratio of 1:1. Typically useful for remote sensing data (depending on your projection), hence it defaults to TRUE.
-Note howver, that this does not apply if (ggLayer=FALSE
).
-
-geom_raster
-
-Logical. If FALSE
annotation_raster is used, otherwise geom_raster()+scale_fill_identity is used.
-Note that you can't use scale_fill* in addition to the latter, because it already requires scale_fill_identity().
-
-nullValue
-
-Numeric. Intensity value used for NULL layers in color compositing. E.g. set g=NULL and fix green value at 0.5 (defaults to 0).
-
-
-
-
-
Details
-
-
Functionality is based on plotRGB
from the raster package.
-
-
-
-
Value
-
-
-
-
-
- ggObj = TRUE
: ggplot2 plot
-
-
-
- ggLayer = TRUE
: ggplot2 layer to be combined with an existing ggplot2
-
-
-
- ggObj = FALSE
: data.frame in long format suitable for plotting with ggplot2, includes the pixel values and the calculated colors
-
-
-
-
-
-
-
-
-
-
-
See Also
-
-
ggR , fortifySpatRaster
-
-
-
-
Examples
-
-
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))
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/histMatch.html b/histMatch.html
deleted file mode 100644
index 4f759c4..0000000
--- a/histMatch.html
+++ /dev/null
@@ -1,164 +0,0 @@
-R: Image to Image Contrast Matching
-
-
-
-
-
-
-
-
-
-
-
-
-
-
histMatch {RStoolbox} R Documentation
-
-
Image to Image Contrast Matching
-
-
Description
-
-
Performs image to image contrast adjustments based on histogram matching using empirical cumulative
-distribution functions from both images.
-
-
-
-
Usage
-
-
histMatch(
- x,
- ref,
- xmask = NULL,
- refmask = NULL,
- nSamples = 1e+05,
- intersectOnly = TRUE,
- paired = TRUE,
- forceInteger = FALSE,
- returnFunctions = FALSE,
- ...
-)
-
-
-
-
Arguments
-
-
-x
-
-RasterLayer or SpatRaster. Source raster which is to be modified.
-
-ref
-
-RasterLayer or SpatRaster. Reference raster, to which x will be matched.
-
-xmask
-
-RasterLayer or SpatRaster. Mask layer for x
to exclude pixels which might distort the histogram, i.e. are not present in ref
. Any NA pixel in xmask
will be ignored (maskvalue = NA
).
-
-refmask
-
-RasterLayer or SpatRaster. Mask layer for ref
. Any NA pixel in refmask
will be ignored (maskvalue = NA
).
-
-nSamples
-
-Integer. Number of random samples from each image to build the histograms.
-
-intersectOnly
-
-Logical. If TRUE
sampling will only take place in the overlap extent of the two rasters. Otherwise the full rasters will be used for sampling.
-
-paired
-
-Logical. If TRUE
the corresponding pixels will be used in the overlap.
-
-forceInteger
-
-Logical. Force integer output.
-
-returnFunctions
-
-Logical. If TRUE
the matching functions will be returned instead of applying them to x
.
-
-...
-
-Further arguments to be passed to writeRaster .
-
-
-
-
-
Value
-
-
A SpatRaster of x
adjusted to the histogram of ref
. If returnFunctions = TRUE
a list of functions (one for each layer) will be returned instead.
-
-
-
-
Note
-
-
x
and ref
must have the same number of layers.
-
-
-
-
References
-
-
Richards and Jia: Remote Sensing Digital Image Analysis. Springer, Berlin, Heidelberg, Germany, 439pp.
-
-
-
-
Examples
-
-
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 in matrix(z, nrow = nrow(rr), ncol = ncol(rr), byrow = TRUE): 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 in matrix(z, nrow = nrow(rr), ncol = ncol(rr), byrow = TRUE): 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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/index.html b/index.html
index 4651107..f5b0815 100644
--- a/index.html
+++ b/index.html
@@ -1,9 +1,144 @@
-
-
-Documentation of the RStoolbox package
-
-
-
-
-
+
+
+
+
+
+
+
+
+Remote Sensing Data Analysis • RStoolbox
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to contents
+
+
+
+
+
+
# RStoolbox
+
+RStoolbox is an R package providing a wide range of tools for your every-day remote sensing processing needs. The available tool-set covers many aspects from data import, pre-processing, data analysis, image classification and graphical display. RStoolbox builds upon the terra package, which makes it suitable for processing large data-sets even on smaller workstations.
+For more details have a look at the functions overview .
+
+
Installation
+
+
The package is available on CRAN and can be installed as usual via
+
install.packages ("RStoolbox" )
+
To install the latest version from GitHub you need to have r-base-dev (Linux) or Rtools (Windows) installed. Then run the following lines:
+
library (devtools)
+install_github ("bleutner/RStoolbox" )
+
+
+
+
+
+
+
+
+
+
Developers
+
+Benjamin Leutner Author
+Ned Horning Author
+Jakob Schwalb-Willmann Author
+Konstantin Mueller Author, maintainer
+More about authors...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/link.svg b/link.svg
new file mode 100644
index 0000000..88ad827
--- /dev/null
+++ b/link.svg
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/logo.png b/logo.png
new file mode 100644
index 0000000..f3ee20b
Binary files /dev/null and b/logo.png differ
diff --git a/lsat.html b/lsat.html
deleted file mode 100644
index 80a3d2f..0000000
--- a/lsat.html
+++ /dev/null
@@ -1,48 +0,0 @@
-R: Landsat 5TM Example Data
-
-
-
-
-
-
-
-
-
-
-
-
-
-
lsat {RStoolbox} R Documentation
-
-
Landsat 5TM Example Data
-
-
Description
-
-
Subset of Landsat 5 TM Scene: LT52240631988227CUB02
-Contains all seven bands in DN format.
-
-
-
-
Usage
-
-
lsat
-
-
-
-
Examples
-
-
ggRGB(lsat, stretch = "lin")
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/mesma.html b/mesma.html
deleted file mode 100644
index f80669c..0000000
--- a/mesma.html
+++ /dev/null
@@ -1,135 +0,0 @@
-R: Multiple Endmember Spectral Mixture Analysis (Spectral...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
mesma {RStoolbox} R Documentation
-
-
Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing)
-
-
Description
-
-
mesma
performs a multiple endmember spectral mixture analysis on a multiband raster image.
-
-
-
-
Usage
-
-
mesma(img, em, method = "NNLS", iterate = 400, tolerance = 1e-08, ..., verbose)
-
-
-
-
Arguments
-
-
-img
-
-RasterLayer or RasterBrick or SpatRaster. Remote sensing imagery (usually hyperspectral).
-
-em
-
-Matrix or data.frame with spectral endmembers. Rows represent a single endmember of a class, columns represent the spectral bands (i.e. columns correspond to number of bands in img
). Number of rows needs to be > 1.
-
-method
-
-Character. Select an unmixing method. Currently, only "NNLS" is implemented. Default is "NNLS".
-
-
-
-
-iterate
-
-Integer. Set maximum iteration per pixel. Processing time could increase the more iterations are made possible. Default is 400.
-
-tolerance
-
-Numeric. Tolerance limit representing a nearly zero minimal number. Default is 1e-8.
-
-...
-
-further arguments passed to writeRaster .
-
-verbose
-
-Logical. Prints progress messages during execution.
-
-
-
-
-
Value
-
-
SpatRaster. The object will contain one band per endmember, with each value representing the estimated presence probability of the endmember per pixel (0 to 1), and an RMSE band.
-
-
-
-
Note
-
-
Depending on iterate
and tolerance
settings, the sum of estimated presence probabilites per pixel varies around 1.
-
-
-
-
Author(s)
-
-
Jakob Schwalb-Willmann
-
-
-
-
References
-
-
Franc, V., Hlaváč, V., & Navara, M. (2005). Sequential coordinate-wise algorithm for the non-negative least squares problem. In: International Conference on Computer Analysis of Images and Patterns (pp. 407-414). Berlin, Heidelberg.
-
-
-
-
Examples
-
-
#load packages
-library(terra)
-library(RStoolbox)
-
-
-#make up some endmember spectra: water and land
-em_names <- c("water", "land")
-pts <- data.frame(class=em_names, cell = c(47916,5294))
-em <- lsat[pts$cell]
-rownames(em) <- em_names
-
-#unmix the image for water and land
-probs <- mesma(lsat, em, method = "NNLS")
-
-#take a look
-terra::hist(probs$water)
-
-
-
terra::plot(probs$water, col = c("white","blue"))
-
-
-
terra::hist(probs$land)
-
-
-
terra::plot(probs$land, col = c("white","brown"))
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/news/index.html b/news/index.html
new file mode 100644
index 0000000..ddcbb12
--- /dev/null
+++ b/news/index.html
@@ -0,0 +1,327 @@
+
+Changelog • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
+
+
New:
+
+mesma()
now better differentiates SMA and MESMA: For single endmember unmixing, each supplied endmember represents a class to unmix (row by row). For multiple endmemeber unmixing, the column class
can be used to group endmembers by class. If multiple endmembers per class are provided, mesma()
will compute a number of SMA (determined through the new argument n_models
) for multiple endmember combinations drawn from endmembers and will select the best fit per pixel based on the lowest RMSE. See ?mesma
for details (fixes #57 , reported by @ytarazona )
+
+
Changes:
+
+mesma()
now implements the sum to one constraint by default (argument sum_to_one
) (fixes #62 , reported by @michaeldorman )
+added a new example to mesma()
to reflect the changes
+
+
+
+
CRAN release: 2022-03-07
+
+
New:
+
+rasterCVA()
by default no longer enforces a minimal change magnitude (can still be accomplished with the tmf
argument). Also a new argument nct
allows to fix this threshold to a user selected value instead of deriving it based on the median of the observed change magnitudes.
+
+unsuperClass()
has a new argument output
which allows to return the distances to all cluster centers as raster layers, instead of the class itself
+added spectral index kNDVI in spectralIndices()
as suggested by Camps-Valls et al (2021)
+added support for terra::SpatRast
objects throughout RStoolbox (as alternative to raster
objects). Note: internal functionality is still based on raster
.
+
+
+
+
+
+
CRAN release: 2019-07-23
+
+
New:
+
added several Sentinel-2 optimized spectral indices relying on red-edge bands: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)
+
+
+
Fixes:
+
+readSLI()
and writeSLI()
now handle endian of binary spectral libraries correctly (#47 , fix contributed by @aloboa )
+fix calculation of prediction probabilities in superClass()
(reported by Benson Kemboi)
+adapt to raster 2.9.5 API changes
+fix order of thermal calibration coefficients for Landsat 8 L1 MTL metadata in readMeta
(reported by Xiaoma Li)
+fixed an issue where readSLI()
did not find header files with dots in pathnames (#51 , reported by @aloboa )
+
+
+
Changes:
+
modified readSLI label parsing. Internal white space is now converted to underscores (#52 )
+
+
+
CRAN release: 2019-01-08
+
+
New:
+
function oneHotEncode()
: splits a single rasterLayer into multiple layers (one per class) with one-hot encoding, i.e. pixel value = 1 for matches, pixel value = 0 for all other classes (background).
+
+ggR()
can now display more than one layer. Each layer can be plotted to a subplot in a multi-panel figure.
+
+encodeQA()
, decodeQA()
and classifyQA()
can now deal with the new QA format introduced with Landsat Collection data. Legacy QA designations can still be interpreted by setting the legacy
argument.
+new predict()
method for unsupervised classification models (unsuperClass()
).
+
+
+
Changes:
+
all radCor()
DOS methods now work for Landsat 8 OLI
+
+
Fixes:
+
fix unsuperClass()
for algorithms other than Hartigan-Wong (reported by Alex Ilich)
+
+
+
+
+
New:
+
added tasseledCap()
coefficients for Quickbird, Spot5 and RapidEye
+
+
Changes:
+
+readEE()
‘Date’ column is now returned as POSIXct instead of POSIXlt
+
+
+
+
CRAN release: 2018-04-09
+
+
Fixes:
+
fixed non-portable c++ headers
+
+
+
CRAN release: 2018-04-05
+
+
New:
+
function mesma()
for spectral unmixing (#33 , provided by Jakob Schwalb-Willmann)
+
+
Fixes:
+
improved NA handling and faster implementation of mlc classifier (#32 , pull request by Neal Fultz)
+adapt to upcoming caret version (new constraint caret >= 6.0-79)
+
+
+
+
CRAN release: 2017-11-10
+
+
Fixes:
+
fix tests for upcoming raster version
+
+
+
CRAN release: 2017-08-28
+
+
Fixes:
+
adapt to new caret version
+fix readEE()
for new EarthExplorer formats
+corrected sign of greenness tasseledCap()
coefficient for Landsat5 TM band 1 (reported by Thomas Day)
+adapt readMeta()
and stackMeta()
to new Landsat collection 1 metadata
+
+
+
+
CRAN release: 2017-04-15
+
+
New:
+
+spectralIndices()
can now apply a mask internally, e.g. to exclude cloud pixels. New arguments are: maskLayer
and maskValue
(suggested by Andrea Hess).
+added spectral index GNDWI
+
+
+
Fixes:
+
update readEE()
to deal with new EarthExplorer export columns (reported by Christian Bauer)
+
+
+
CRAN release: 2017-01-10
+
+
New:
+
+spectralIndices()
has a new argument skipRefCheck, which skips the heuristic check for reflectance-like values [0,1] which is run if EVI/EVI2 are requested. This can be usefull if clouds with reflectance > 1.5 are part of the image.
+
+superClass()
now returns the geometries which were used for validation, e.g. polygons (under v a l i d a t i o n geometry) and also the exact samples taken for validation including cell number and coordinates (v a l i d a t i o n validationSamples)
+added example data-set for spectral library see ?readSLI
+increased overall test coverage
+
+
+
Changes:
+
ESUN lookup tables for radCor()
are adjusted to match current USGS recommendations from: https://landsat.usgs.gov/esun
+
+
+spectralIndices()
swir wavelength ranges are now defined consistently and correctly. Bands formerly provided as swir1 (version <1.7.0) should now (>=1.7.0) be provided as swir2 and former swir2 as swir3 respectively (see docu). The actual calculations were correct, but the naming was off.
+
+
+
Fixes:
+
fix ggR()
and ggRGB()
in annotation mode (default). No image was drawn and excessive memory allocation requested (= RStudio crash) (reported by Christian Walther)
+fix spectralIndices()
documentation for NDWI. Formula was based on McFeeters1996 but attributed to Gao1996. Now there is NDWI (McFeeters) and NDWI2 (Gao) (reported by Christian Bauer)
+
+estimateHaze()
now ensures correct histogram order, which could be off when raster had to read from disk (reported by Xavier Bailleau).
+
+readMeta()
now makes concise bandnames also for Landsat Collection MTL files.
+fix radCor()
for Landsat 4 TM (reported by Thomas Day)
+
+classifyQA()
confidence layer for type=‘water’ now correctly returns only confidence levels in [1,3]
+enable reading ENVI plot files in ASCII mode with readSLI()
+
+Deprecated: * spectralIndices()
index LSWI
has been deprecated, as it is identical with the now available NDWI2.
+
+
+
+
CRAN release: 2016-11-07
+
+
Fixes:
+
fix import issue: replace deprecated export from caret
+
+
+
CRAN release: 2016-10-06
+
+
Changes:
+
If the bandSet argument in radCor()
is used to process only a subset of bands it will no longer return unprocessed bands along with processed bands. Instead only processed bands are returned.
+By default superClass()
will now use dataType = ‘INT2S’ for classification maps to avoid issues with raster NA handling in INT1U
+Allow reading and importing from Landsat MSS MTL files with readMeta()
and stackMeta()
(@aszeitz , #7 )
+
+
+
Fixes:
+
fix readMeta time-stamp conversion now correctly set to GMT time (@mraraju , #12 )
+radCor caused R to crash if bandSet was a single band
+fix single RasterLayer capability for superClass
+spectralIndices now calculates all documented indices if specified to do so (@mej1d1 , #6 )
+unsuperClass predicted map now handles NAs properly
+pifMatch did not return adjusted image (@tmb3006 , #13 )
+Deprecated: * argument norm
was dropped from rasterPCA, because it was effectively a duplicate of the standardized pca (spca) argument in the same function.
+
+
+
+
CRAN release: 2016-01-28
+
+
New:
+
new function validateMap()
for assessing map accuracy separately from model fitting, e.g. after majority or MMU filtering
+new function getValidation()
to extract specific validation results of superClass objects (proposed by James Duffy)
+new spectral index NDVIc (proposed by Jeff Evans)
+new argument scaleFactor for spectralIndices()
for calculation of EVI/EVI2 based on scaled reflectance values.
+implemented dark object subtraction radCor(..,method=‘sdos’) for Landsat 8 data (@BayAludra , #4 )
+
+
+
Changes:
+
superClass based on polygons now considers only pixels which have their center coordinate within a polygon
+rasterCVA now returns angles from 0 to 360° instead of 0:45 by quadrant (reported by Martin Wegmann)
+improved dark object DN estimation based on maximum slope of the histogram in estimateHaze()
(@BayAludra , #4 )
+
+
+
Fixes:
+
superClass failed when neither valData or trainPartition was specified. regression introduced in 0.1.3 (reported by Anna Stephani)
+spectralIndices valid value range of EVI/EVI2 now [-1,1]
+radCor returned smallest integer instead of NA for some NA pixels
+fix ‘sdos’ for non-contiguous bands in radCor (@BayAludra , #4 )
+
+
+
+
CRAN release: 2015-11-28
+
+
New:
+
new logical argument predict()
for superClass. Disables prediction of full raster (validation is still conducted).
+new generic predict() function for superClass objects. Useful to separate model training and prediction.
+new example data set (landcover training polygons) for lsat example data under /extdata/trainingPolygons.rds
+
+
+
Fixes:
+
fix histMatch for single layers (affected also ‘ihs’ pan-sharpening)
+fix superClass validation sampling for factors (character based factors could lead to wrong factor conversions and wrong validation results)
+improved handling of of training polygons with overlaps and shared borders in superClass
+improved checks and error messages for insufficient training polygons
+
+
+
+
CRAN release: 2015-11-04
+
+
New:
+
New model for superClass: maximum likelihood classification (model = “mlc”)
+
+
+
Fixes:
+
Restrict calculation of EVI/EVI2 to reflectance data (#3 )
+Enforce valid value ranges in radCor()
: radiance: [0,+Inf], reflectance: [0,1]. Includes a new argument clamp
to turn this on or off (on by default).
+
+
+
+
CRAN release: 2015-09-08
+
Added kernlab to suggested packages to be able to test examples
+
+
+
CRAN release: 2015-09-05
+
Initial release to CRAN (2015-09-05) with the 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)
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/normImage.html b/normImage.html
deleted file mode 100644
index df1c6cc..0000000
--- a/normImage.html
+++ /dev/null
@@ -1,79 +0,0 @@
-R: Normalize Raster Images: Center and Scale
-
-
-
-
-
-
-
-
-
-
-
-
-
-
normImage {RStoolbox} R Documentation
-
-
Normalize Raster Images: Center and Scale
-
-
Description
-
-
For each pixel subtracts the mean of the raster layer and optionally divide by its standard deviation.
-
-
-
-
Usage
-
-
normImage(img, norm = TRUE, ...)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster. Image to transform. Transformation will be performed separately for each layer.
-
-norm
-
-Logical. Perform normalization (scaling) in addition to centering, i.e. divide by standard deviation.
-
-...
-
-further arguments passed to writeRaster .
-
-
-
-
-
Value
-
-
Returns a SpatRaster with the same number layers as input layers with each layer being centered and optionally normalized.
-
-
-
-
Examples
-
-
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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/oneHotEncode.html b/oneHotEncode.html
deleted file mode 100644
index e41f7ae..0000000
--- a/oneHotEncode.html
+++ /dev/null
@@ -1,102 +0,0 @@
-R: One-hot encode a raster or vector
-
-
-
-
-
-
-
-
-
-
-
-
-
-
oneHotEncode {RStoolbox} R Documentation
-
-
One-hot encode a raster or vector
-
-
Description
-
-
Splits a categorical raster layer (or a vector) into a multilayer raster (or matrix).
-
-
-
-
Usage
-
-
oneHotEncode(img, classes, background = 0, foreground = 1, na.rm = FALSE, ...)
-
-
-
-
Arguments
-
-
-img
-
-RasterLayer or SpatRaster or integer/numeric vector containing multiple classes
-
-classes
-
-integer: vector of classes which should be extracted
-
-background
-
-integer: background value (default = 0)
-
-foreground
-
-integer: foreground value (default = 1)
-
-na.rm
-
-logical: if TRUE
, NA
s will be coerced to the background
value.
-
-...
-
-further arguments passed to writeRaster . Ignored if img is not a SpatRaster, but a numeric/integer vector or matrix
-
-
-
-
-
Value
-
-
A SpatRaster with as many layers as there are classes.
-Pixels matching the class of interest are set to 1, backround values by default are set to 0 (see background argument)
-
-
-
-
Examples
-
-
## No test:
-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
-
-
## End(No test)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/panSharpen.html b/panSharpen.html
deleted file mode 100644
index b13ad78..0000000
--- a/panSharpen.html
+++ /dev/null
@@ -1,147 +0,0 @@
-R: Pan Sharpen Imagery / Image Fusion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
panSharpen {RStoolbox} R Documentation
-
-
Pan Sharpen Imagery / Image Fusion
-
-
Description
-
-
provides different methods for pan sharpening a coarse resolution (typically multispectral) image with
-a higher reolution panchromatic image. Values of the pan-chromatic and multispectral images must be of the same scale, (e.g. from 0:1, or all DNs from 0:255)
-
-
-
-
Usage
-
-
panSharpen(img, pan, r, g, b, pc = 1, method = "brovey", norm = TRUE)
-
-
-
-
Arguments
-
-
-img
-
-RasterLayer or SpatRaster. Coarse resolution multispectral image
-
-pan
-
-RasterLayer or SpatRaster. High resolution image, typically panchromatic.
-
-r
-
-Character or Integer. Red band in img
. Only relevant if method!='pca'
-
-g
-
-Character or Integer. Green band in img
. Only relevant if method!='pca'
-
-b
-
-Character or Integer. Blue band in img
. Only relevant if method!='pca'
-
-pc
-
-Integer. Only relevant if method = 'pca'
. Which principal component to replace. Usually this should be the first component (default). Only if the first component is dominated by something else than brightness it might be worth a try to use the second component.
-
-method
-
-Character. Choose method from c("pca", "ihs", "brovey").
-
-norm
-
-Logical. Rescale pan image to match the 1st PC component. Only relevant if method = 'pca'
. If TRUE
only min and max are matched to the 1st PC. If FALSE
pan will be histogram matched to the 1st PC.
-
-
-
-
-
Details
-
-
Pan sharpening options:
-
-
-
-method='pca'
: Performs a pca using rasterPCA . The first component is then swapped for the pan band an the PCA is rotated backwards.
-
-
-method='ihs'
: Performs a color space transform to Intensity-Hue-Saturation space, swaps intensity for the histogram matched pan and does the backwards transformation.
-
-
-method='brovey'
: Performs Brovey reweighting. Pan and img must be at the same value scale (e.g. 0:1, or 0:255) otherwise you'll end up with psychodelic colors.
-
-
-
-
-
-
Value
-
-
pan-sharpened SpatRaster
-
-
-
-
Examples
-
-
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 in matrix(z, nrow = nrow(rr), ncol = ncol(rr), byrow = TRUE): 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 in matrix(z, nrow = nrow(rr), ncol = ncol(rr), byrow = TRUE): data length [88350] is not a sub-multiple
-## or multiple of the number of columns [287]
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/pifMatch.html b/pifMatch.html
deleted file mode 100644
index c191f0f..0000000
--- a/pifMatch.html
+++ /dev/null
@@ -1,172 +0,0 @@
-R: Pseudo-Invariant Features based Image Matching
-
-
-
-
-
-
-
-
-
-
-
-
-
-
pifMatch {RStoolbox} R Documentation
-
-
Pseudo-Invariant Features based Image Matching
-
-
Description
-
-
Match one scene to another based on linear regression of pseudo-invariant features (PIF).
-
-
-
-
Usage
-
-
pifMatch(
- img,
- ref,
- method = "cor",
- quantile = 0.95,
- returnPifMap = TRUE,
- returnSimMap = TRUE,
- returnModels = FALSE
-)
-
-
-
-
Arguments
-
-
-img
-
-RasterStack or RasterBrick or SpatRaster. Image to be adjusted.
-
-ref
-
-RasterStack or RasterBrick or SpatRaster. Reference image.
-
-method
-
-Method to calculate pixel similarity. Options: euclidean distance ('ed'), spectral angle ('sam') or pearson correlation coefficient ('cor').
-
-quantile
-
-Numeric. Threshold quantile used to identify PIFs
-
-returnPifMap
-
-Logical. Return a binary raster map ot pixels which were identified as pesudo-invariant features.
-
-returnSimMap
-
-Logical. Return the similarity map as well
-
-returnModels
-
-Logical. Return the linear models along with the adjusted image.
-
-
-
-
-
Details
-
-
The function consists of three main steps:
-First, it calculates pixel-wise similarity between the two rasters and identifies pseudo-invariant pixels based on
-a similarity threshold.
-In the second step the values of the pseudo-invariant pixels are regressed against each other in a linear model for each layer.
-Finally the linear models are applied to all pixels in the img
, thereby matching it to the reference scene.
-
-
Pixel-wise similarity can be calculated using one of three methods: euclidean distance (method = "ed"
), spectral angle ("sam"
) or pearsons correlation coefficient ("cor"
).
-The threshold is defined as a similarity quantile. Setting quantile=0.95
will select all pixels with a similarity above the 95% quantile as pseudo-invariant features.
-
-
Model fitting is performed with simple linear models (lm
); fitting one model per layer.
-
-
-
-
Value
-
-
Returns a List with the adjusted image and intermediate products (if requested).
-
-
-
- img
: the adjusted image
-
-
- simMap
: pixel-wise similarity map (if returnSimMap = TRUE
)
-
-
- pifMap
: binary map of pixels selected as pseudo-invariant features (if returnPifMap = TRUE
)
-
-
- models
: list of linear models; one per layer (if returnModels = TRUE
)
-
-
-
-
-
-
Examples
-
-
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)
-## No test:
-## 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, Adjusted R-squared: 0.976
-## F-statistic: 1.811e+05 on 1 and 4447 DF, p-value: < 2.2e-16
-
-
## End(No test)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/pipe.html b/pipe.html
deleted file mode 100644
index 0a41f1c..0000000
--- a/pipe.html
+++ /dev/null
@@ -1,54 +0,0 @@
-R: Pipe operator
-
-
-
-
-
-
-
-
-
%>% {RStoolbox} R Documentation
-
-
Pipe operator
-
-
Description
-
-
See magrittr::%>%
for details.
-
-
-
-
Usage
-
-
lhs %>% rhs
-
-
-
-
Arguments
-
-
-lhs
-
-A value or the magrittr placeholder.
-
-rhs
-
-A function call using the magrittr semantics.
-
-
-
-
-
Value
-
-
The result of calling 'rhs(lhs)'.
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/pkgdown.js b/pkgdown.js
new file mode 100644
index 0000000..5fccd9c
--- /dev/null
+++ b/pkgdown.js
@@ -0,0 +1,156 @@
+/* http://gregfranko.com/blog/jquery-best-practices/ */
+(function($) {
+ $(function() {
+
+ $('nav.navbar').headroom();
+
+ Toc.init({
+ $nav: $("#toc"),
+ $scope: $("main h2, main h3, main h4, main h5, main h6")
+ });
+
+ if ($('#toc').length) {
+ $('body').scrollspy({
+ target: '#toc',
+ offset: $("nav.navbar").outerHeight() + 1
+ });
+ }
+
+ // Activate popovers
+ $('[data-bs-toggle="popover"]').popover({
+ container: 'body',
+ html: true,
+ trigger: 'focus',
+ placement: "top",
+ sanitize: false,
+ });
+
+ $('[data-bs-toggle="tooltip"]').tooltip();
+
+ /* Clipboard --------------------------*/
+
+ function changeTooltipMessage(element, msg) {
+ var tooltipOriginalTitle=element.getAttribute('data-original-title');
+ element.setAttribute('data-original-title', msg);
+ $(element).tooltip('show');
+ element.setAttribute('data-original-title', tooltipOriginalTitle);
+ }
+
+ if(ClipboardJS.isSupported()) {
+ $(document).ready(function() {
+ var copyButton = " ";
+
+ $("div.sourceCode").addClass("hasCopyButton");
+
+ // Insert copy buttons:
+ $(copyButton).prependTo(".hasCopyButton");
+
+ // Initialize tooltips:
+ $('.btn-copy-ex').tooltip({container: 'body'});
+
+ // Initialize clipboard:
+ var clipboard = new ClipboardJS('[data-clipboard-copy]', {
+ text: function(trigger) {
+ return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, "");
+ }
+ });
+
+ clipboard.on('success', function(e) {
+ changeTooltipMessage(e.trigger, 'Copied!');
+ e.clearSelection();
+ });
+
+ clipboard.on('error', function() {
+ changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
+ });
+
+ });
+ }
+
+ /* Search marking --------------------------*/
+ var url = new URL(window.location.href);
+ var toMark = url.searchParams.get("q");
+ var mark = new Mark("main#main");
+ if (toMark) {
+ mark.mark(toMark, {
+ accuracy: {
+ value: "complementary",
+ limiters: [",", ".", ":", "/"],
+ }
+ });
+ }
+
+ /* Search --------------------------*/
+ /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */
+ // Initialise search index on focus
+ var fuse;
+ $("#search-input").focus(async function(e) {
+ if (fuse) {
+ return;
+ }
+
+ $(e.target).addClass("loading");
+ var response = await fetch($("#search-input").data("search-index"));
+ var data = await response.json();
+
+ var options = {
+ keys: ["what", "text", "code"],
+ ignoreLocation: true,
+ threshold: 0.1,
+ includeMatches: true,
+ includeScore: true,
+ };
+ fuse = new Fuse(data, options);
+
+ $(e.target).removeClass("loading");
+ });
+
+ // Use algolia autocomplete
+ var options = {
+ autoselect: true,
+ debug: true,
+ hint: false,
+ minLength: 2,
+ };
+ var q;
+async function searchFuse(query, callback) {
+ await fuse;
+
+ var items;
+ if (!fuse) {
+ items = [];
+ } else {
+ q = query;
+ var results = fuse.search(query, { limit: 20 });
+ items = results
+ .filter((x) => x.score <= 0.75)
+ .map((x) => x.item);
+ if (items.length === 0) {
+ items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}];
+ }
+ }
+ callback(items);
+}
+ $("#search-input").autocomplete(options, [
+ {
+ name: "content",
+ source: searchFuse,
+ templates: {
+ suggestion: (s) => {
+ if (s.title == s.what) {
+ return `${s.dir} > ${s.title}
`;
+ } else if (s.previous_headings == "") {
+ return `${s.dir} > ${s.title}
> ${s.what}`;
+ } else {
+ return `${s.dir} > ${s.title}
> ${s.previous_headings} > ${s.what}`;
+ }
+ },
+ },
+ },
+ ]).on('autocomplete:selected', function(event, s) {
+ window.location.href = s.path + "?q=" + q + "#" + s.id;
+ });
+ });
+})(window.jQuery || window.$)
+
+
diff --git a/pkgdown.yml b/pkgdown.yml
new file mode 100644
index 0000000..b8ee0f5
--- /dev/null
+++ b/pkgdown.yml
@@ -0,0 +1,9 @@
+pandoc: 2.7.3
+pkgdown: 2.0.8
+pkgdown_sha: ~
+articles: {}
+last_built: 2024-04-18T08:18Z
+urls:
+ reference: https://bleutner.github.io/RStoolbox/reference
+ article: https://bleutner.github.io/RStoolbox/articles
+
diff --git a/predict.unsuperClass.html b/predict.unsuperClass.html
deleted file mode 100644
index b9cda0c..0000000
--- a/predict.unsuperClass.html
+++ /dev/null
@@ -1,82 +0,0 @@
-R: Predict a raster map based on a unsuperClass model fit.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
predict.unsuperClass {RStoolbox} R Documentation
-
-
Predict a raster map based on a unsuperClass model fit.
-
-
Description
-
-
applies a kmeans cluster model to all pixels of a raster.
-Useful if you want to apply a kmeans model of scene A to scene B.
-
-
-
-
Usage
-
-
## S3 method for class 'unsuperClass'
-predict(object, img, output = "classes", ...)
-
-
-
-
Arguments
-
-
-object
-
-unsuperClass object
-
-img
-
-Raster object. Layernames must correspond to layernames used to train the superClass model, i.e. layernames in the original raster image.
-
-output
-
-Character. Either 'classes' (kmeans class; default) or 'distances' (euclidean distance to each cluster center).
-
-...
-
-further arguments to be passed to writeRaster , e.g. filename
-
-
-
-
-
Value
-
-
Returns a raster with the K-means distances base on your object passed in the arguments.
-
-
-
-
Examples
-
-
## Load training data
-
-## Perform unsupervised classification
-uc <- unsuperClass(rlogo, nClasses = 10)
-
-## Apply the model to another raster
-map <- predict(uc, rlogo)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/radCor.html b/radCor.html
deleted file mode 100644
index 28c85e6..0000000
--- a/radCor.html
+++ /dev/null
@@ -1,221 +0,0 @@
-R: Radiometric Calibration and Correction
-
-
-
-
-
-
-
-
-
-
-
-
-
-
radCor {RStoolbox} R Documentation
-
-
Radiometric Calibration and Correction
-
-
Description
-
-
Implements several different methods for radiometric calibration and correction of Landsat data.
-You can either specify a metadata file, or supply all neccesary values manually.
-With proper parametrization apref and sdos should work for other sensors as well.
-
-
-
-
Usage
-
-
radCor(
- img,
- metaData,
- method = "apref",
- bandSet = "full",
- hazeValues,
- hazeBands,
- atmosphere,
- darkProp = 0.01,
- clamp = TRUE,
- verbose
-)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster
-
-metaData
-
-object of class ImageMetaData or a path to the meta data (MTL) file.
-
-method
-
-Radiometric conversion/correction method to be used. There are currently four methods available (see Details):
-"rad", "apref", "sdos", "dos", "costz".
-
-bandSet
-
-Numeric or character. original Landsat band numbers or names in the form of ("B1", "B2" etc). If set to 'full' all bands in the solar (optical) region will be processed.
-
-hazeValues
-
-Numeric. Either a vector with dark DNs per hazeBand
(method = 'sdos'); possibly estimated using estimateHaze .
-Or the 'starting haze value' (DN) for the relative scattering models in method = 'dos' or 'costz'
. If not provided, hazeValues will be estimated in an automated fashion for all hazeBands
.
-Argument only applies to methods 'sdos', 'dos' and 'costz'.
-
-hazeBands
-
-Character or integer. Bands corresponding to hazeValues
(method = 'sdos') or band to select starting haze value from ('dos' or 'costz').
-
-atmosphere
-
-Character. Atmospheric characteristics. Will be estimated if not expicilty provided. Must be one of "veryClear", "clear", "moderate", "hazy"
or "veryHazy"
.
-
-darkProp
-
-Numeric. Estimated proportion of dark pixels in the scene. Used only for automatic guessing of hazeValues (typically one would choose 1 or 2%).
-
-clamp
-
-Logical. Enforce valid value range. By default reflectance will be forced to stay within [0,1] and radiance >= 0 by replacing invalid values with the correspinding boundary, e.g. -0.1 will become 0.
-
-verbose
-
-Logical. Print status information.
-
-
-
-
-
Details
-
-
The atmospheric correction methods (sdos, dos and costz) apply to the optical (solar) region of the spectrum and do not affect the thermal band.
-
-
Dark object subtraction approaches rely on the estimation of atmospheric haze based on *dark* pixels. Dark pixels are assumed to have zero reflectance, hence the name.
-It is then assumed further that any radiation originating from such *dark* pixels is due to atmospheric haze and
-not the reflectance of the surface itself.
-
-
The folloiwing methods
are available:
-
-
-
-
-
-rad Radiance
-
-
-
-apref Apparent reflectance (top-of-atmosphere reflectance)
-
-
-
-dos Dark object subtratction following Chavez (1989)
-
-
-
-costz Dark object subtraction following Chavez (1996)
-
-
-
-sdos Simple dark object subtraction. Classical DOS, Lhaze must be estimated for each band separately.
-
-
-
-
-
-
If either "dos" or "costz" are selected, radCor will use the atmospheric haze decay model described by Chavez (1989).
-Depending on the atmosphere
the following coefficients are used:
-
-
-
-
-
-veryClear \lambda^{-4.0}
-
-
-
-clear \lambda^{-2.0}
-
-
-
-moderate \lambda^{-1.0}
-
-
-
-hazy \lambda^{-0.7}
-
-
-
-veryHazy \lambda^{-0.5}
-
-
-
-
-
-
For Landsat 8, no values for extra-terrestrial irradiation (esun) are provided by NASA. These are, however, neccessary for DOS-based approaches.
-Therefore, these values were derived from a standard reference spectrum published by Thuillier et al. (2003) using the Landsat 8 OLI spectral response functions
-(for details, see http://bleutner.github.io/RStoolbox/r/2016/01/26/estimating-landsat-8-esun-values ).
-
-
The implemented sun-earth distances neglect the earth's eccentricity. Instead we use a 100 year daily average (1979-2070).
-
-
-
-
Value
-
-
SpatRaster with top-of-atmosphere radiance (W/(m^2 * srad * \mu m)
), at-satellite brightness temperature (K),
-top-of-atmosphere reflectance (unitless) corrected for the sun angle or at-surface reflectance (unitless).
-
-
-
-
Note
-
-
This was originally a fork of randcorr() function in the landsat package. This version works on SpatRasters and hence is suitable for large rasters.
-
-
-
-
References
-
-
S. Goslee (2011): Analyzing Remote Sensing Data in R: The landsat Package. Journal of Statistical Software 43(4).
-
-
G. Thuillier et al. (2003) THE SOLAR SPECTRAL IRRADIANCE FROM 200 TO 2400 nm AS MEASURED BY THE SOLSPEC SPECTROMETER FROM THE ATLAS AND EURECA MISSIONS. Solar Physics 214(1): 1-22 (
-
-
-
-
Examples
-
-
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)
-## No test:
-lsat_sref <- radCor(lsat_t, metaData = metaData)
-## End(No test)
-
-## 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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/rasterCVA.html b/rasterCVA.html
deleted file mode 100644
index 7321033..0000000
--- a/rasterCVA.html
+++ /dev/null
@@ -1,105 +0,0 @@
-R: Change Vector Analysis
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rasterCVA {RStoolbox} R Documentation
-
-
Change Vector Analysis
-
-
Description
-
-
Calculates angle and magnitude of change vectors.
-Dimensionality is limited to two bands per image.
-
-
-
-
Usage
-
-
rasterCVA(x, y, tmf = NULL, nct = NULL, ...)
-
-
-
-
Arguments
-
-
-x
-
-RasterBrick or RasterStack or SpatRaster with two layers. This will be the reference/origin for the change calculations. Both rasters (y and y) need to correspond to each other, i.e. same resolution, extent and origin.
-
-y
-
-RasterBrick or RasterStack or SpatRaster with two layers. Both rasters (y and y) need to correspond to each other, i.e. same resolution, extent and origin.
-
-tmf
-
-Numeric. Threshold median factor (optional). Used to calculate a threshold magnitude for which pixels are considered stable, i.e. no change. Calculated as tmf * mean(magnitude[magnitude > 0])
.
-
-nct
-
-Numeric. No-change threshold (optional). Alternative to tmf
. Sets an absolute threshold. Change magnitudes below nct
are considered stable and set to NA.
-
-...
-
-further arguments passed to writeRaster
-
-
-
-
-
Details
-
-
Change Vector Analysis (CVA) is used to identify spectral changes between two identical scenes which were acquired at different times.
-CVA is limited to two bands per image. For each pixel it calculates the change vector in the two-dimensional spectral space.
-For example for a given pixel in image A and B for the red and nir band the change vector is calculated for the coordinate pairs: (red_A | nir_A) and (red_B | nir_B).
-
-
The coordinate system is defined by the order of the input bands: the first band defines the x-axis and the second band the y-axis, respectively.
-Angles are returned *in degree* beginning with 0 degrees pointing 'north', i.e. the y-axis, i.e. the second band.
-
-
-
-
Value
-
-
Returns a SpatRaster with two layers: change vector angle and change vector magnitude
-
-
-
-
Examples
-
-
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
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/rasterEntropy.html b/rasterEntropy.html
deleted file mode 100644
index 0d30fa7..0000000
--- a/rasterEntropy.html
+++ /dev/null
@@ -1,75 +0,0 @@
-R: Multi-layer Pixel Entropy
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rasterEntropy {RStoolbox} R Documentation
-
-
Multi-layer Pixel Entropy
-
-
Description
-
-
Shannon entropy is calculated for each pixel based on it's layer values.
-To be used with categorical / integer valued rasters.
-
-
-
-
Usage
-
-
rasterEntropy(img, ...)
-
-
-
-
Arguments
-
-
-img
-
-RasterStack or RasterBrick or SpatRaster
-
-...
-
-additional arguments passed to writeRaster
-
-
-
-
-
Details
-
-
Entropy is calculated as -sum(p log(p)); p being the class frequency per pixel.
-
-
-
-
Value
-
-
SpatRaster "entropy"
-
-
-
-
Examples
-
-
re <- rasterEntropy(rlogo)
-ggR(re, geom_raster = TRUE)
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/rasterPCA.html b/rasterPCA.html
deleted file mode 100644
index beca8b3..0000000
--- a/rasterPCA.html
+++ /dev/null
@@ -1,177 +0,0 @@
-R: Principal Component Analysis for Rasters
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rasterPCA {RStoolbox} R Documentation
-
-
Principal Component Analysis for Rasters
-
-
Description
-
-
Calculates R-mode PCA for RasterBricks or RasterStacks and returns a RasterBrick with multiple layers of PCA scores.
-
-
-
-
Usage
-
-
rasterPCA(
- img,
- nSamples = NULL,
- nComp = nlyr(img),
- spca = FALSE,
- maskCheck = TRUE,
- ...
-)
-
-
-
-
Arguments
-
-
-img
-
-RasterLayer or SpatRaster.
-
-nSamples
-
-Integer or NULL. Number of pixels to sample for PCA fitting. If NULL, all pixels will be used.
-
-nComp
-
-Integer. Number of PCA components to return.
-
-spca
-
-Logical. If TRUE
, perform standardized PCA. Corresponds to centered and scaled input image. This is usually beneficial for equal weighting of all layers. (FALSE
by default)
-
-maskCheck
-
-Logical. Masks all pixels which have at least one NA (default TRUE is reccomended but introduces a slow-down, see Details when it is wise to disable maskCheck).
-Takes effect only if nSamples is NULL.
-
-...
-
-further arguments to be passed to writeRaster , e.g. filename.
-
-
-
-
-
Details
-
-
Internally rasterPCA relies on the use of princomp (R-mode PCA). If nSamples is given the PCA will be calculated
-based on a random sample of pixels and then predicted for the full raster. If nSamples is NULL then the covariance matrix will be calculated
-first and will then be used to calculate princomp and predict the full raster. The latter is more precise, since it considers all pixels,
-however, it may be slower than calculating the PCA only on a subset of pixels.
-
-
Pixels with missing values in one or more bands will be set to NA. The built-in check for such pixels can lead to a slow-down of rasterPCA.
-However, if you make sure or know beforehand that all pixels have either only valid values or only NAs throughout all layers you can disable this check
-by setting maskCheck=FALSE which speeds up the computation.
-
-
Standardised PCA (SPCA) can be useful if imagery or bands of different dynamic ranges are combined. SPC uses the correlation matrix instead of the covariance matrix, which
-has the same effect as using normalised bands of unit variance.
-
-
-
-
Value
-
-
Returns a named list containing the PCA model object ($model) and a SpatRaster with the principal component layers ($object).
-
-
-
-
Examples
-
-
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
-
-
## Warning: package 'gridExtra' was built under R version 4.2.2
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/readEE.html b/readEE.html
deleted file mode 100644
index 383e384..0000000
--- a/readEE.html
+++ /dev/null
@@ -1,112 +0,0 @@
-R: Tidy import tool for EarthExplorer .csv export files
-
-
-
-
-
-
-
-
-
-
-
-
-
-
readEE {RStoolbox} R Documentation
-
-
Tidy import tool for EarthExplorer .csv export files
-
-
Description
-
-
Imports and tidies CSV files exported from EarthExplorer into data.frames and annotates missing fields.
-
-
-
-
Usage
-
-
readEE(x)
-
-
-
-
Arguments
-
-
-x
-
-Character, Character or list. One or more paths to EarthExplorer export files.
-
-
-
-
-
Details
-
-
The EarthExplorer CSV file can be produced from the search results page. Above the results click on 'export results' and select 'comma (,) delimited'.
-
-
Note that only a subset of columns is imported which was deemed interesting. Please contact the maintainer if you think an omited column should be included.
-
-
-
-
Value
-
-
data.frame
-
-
-
-
Examples
-
-
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 Station.Identifier Day.Night
-## 6 LC82240632015157LGN00 224 63 NOMINAL 13.20 LGN DAY
-## 27 LC82240632014186LGN00 224 63 NOMINAL 15.94 LGN DAY
-## 40 LC82240632013327LGN00 224 63 NOMINAL 13.19 LGN DAY
-## 46 LC82240632013215LGN00 224 63 NOMINAL 14.72 LGN DAY
-## 49 LC82240632013167LGN00 224 63 NOMINAL 6.35 LGN DAY
-## Data.Type.Level.1 Date.Acquired Sun.Elevation Sun.Azimuth Geometric.RMSE.Model.X Geometric.RMSE.Model.Y
-## 6 L1T 2015/06/06 51.98871 43.59274 6.244 5.663
-## 27 L1T 2014/07/05 51.01591 44.79093 5.452 5.420
-## 40 L1GT 2013/11/23 61.83434 126.95937 0.000 0.000
-## 46 L1T 2013/08/03 54.43226 51.68815 5.631 5.840
-## 49 L1T 2013/06/16 51.64735 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 Browse.Link Date Doy Year
-## 6 http://earthexplorer.usgs.gov/download/options/4923/LC82240632015157LGN00 NA 2015-06-06 157 2015
-## 27 http://earthexplorer.usgs.gov/download/options/4923/LC82240632014186LGN00 NA 2014-07-05 186 2014
-## 40 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013327LGN00 NA 2013-11-23 327 2013
-## 46 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013215LGN00 NA 2013-08-03 215 2013
-## 49 http://earthexplorer.usgs.gov/download/options/4923/LC82240632013167LGN00 NA 2013-06-16 167 2013
-## Satellite Num
-## 6 LS8 8
-## 27 LS8 8
-## 40 LS8 8
-## 46 LS8 8
-## 49 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)")
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/readMeta.html b/readMeta.html
deleted file mode 100644
index 4126578..0000000
--- a/readMeta.html
+++ /dev/null
@@ -1,131 +0,0 @@
-R: Read Landsat MTL metadata files
-
-
-
-
-
-
-
-
-
-
-
-
-
-
readMeta {RStoolbox} R Documentation
-
-
Read Landsat MTL metadata files
-
-
Description
-
-
Reads metadata and deals with legacy versions of Landsat metadata files and where possible adds missing information (radiometric gain and offset, earth-sun distance).
-
-
-
-
Usage
-
-
readMeta(file, raw = FALSE)
-
-
-
-
Arguments
-
-
-file
-
-path to Landsat MTL file (...MTL.txt)
-
-raw
-
-Logical. If TRUE
the full raw metadata will be returned as a list. if FALSE
(the default) all important metadata are homogenized into a standard format (ImageMetaData) and some information is added.
-
-
-
-
-
Value
-
-
Object of class ImageMetaData
-
-
-
-
Examples
-
-
## 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):
-## dn -> radiance (toa)
-## dn -> brightness temperature (toa)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/readSLI.html b/readSLI.html
deleted file mode 100644
index b4c9ae2..0000000
--- a/readSLI.html
+++ /dev/null
@@ -1,95 +0,0 @@
-R: Read ENVI spectral libraries
-
-
-
-
-
-
-
-
-
-
-
-
-
-
readSLI {RStoolbox} R Documentation
-
-
Read ENVI spectral libraries
-
-
Description
-
-
read/write support for ENVI spectral libraries
-
-
-
-
Usage
-
-
readSLI(path)
-
-
-
-
Arguments
-
-
-path
-
-Path to spectral library file with ending .sli.
-
-
-
-
-
Details
-
-
ENVI spectral libraries consist of a binary data file (.sli) and a corresponding header (.hdr, or .sli.hdr) file.
-
-
-
-
Value
-
-
The spectral libraries are read into a data.frame. The first column contains the wavelengths and the remaining columns contain the spectra.
-
-
-
-
See Also
-
-
writeSLI
-
-
-
-
Examples
-
-
## 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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/reference/ImageMetaData.html b/reference/ImageMetaData.html
new file mode 100644
index 0000000..6819071
--- /dev/null
+++ b/reference/ImageMetaData.html
@@ -0,0 +1,226 @@
+
+ImageMetaData Class — ImageMetaData • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
+
+
Usage
+
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
+)
+
+
+
+
Arguments
+
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 the data, e.g. tiff files
+
+
+bands
+Character vector. Band names
+
+
+quant
+Character vector. Quantity, one of c("dn", "tra", "tre", "sre", "bt", "idx", "angle")
+
+
+cat
+Character vector. Category, e.g. c("image", "pan", "index", "qa", "aux")
+
+
+na
+Numeric vector. No-data value per band
+
+
+vsat
+Numeric vector. Saturation value per band
+
+
+scal
+Numeric vector. Scale factor per band. e.g. if data was scaled to 1000*reflectance for integer conversion.
+
+
+dtyp
+Character vector. Data type per band.
+
+
+calrad
+data.frame. Calibration coefficients for dn->radiance conversion. Must have columns 'gain' and 'offset'. Rows named according to bands
.
+
+
+calref
+data.frame. Calibration coefficients for dn->reflectance conversion. Must have columns 'gain' and 'offset'. Rows named according to bands
.
+
+
+calbt
+data.frame. Calibration coefficients for dn->brightness temperature conversion. Must have columns 'K1' and 'K2'. Rows named according to bands
.
+
+
+radRes
+Numeric vector. Radiometric resolution per band.
+
+
+spatRes
+Numeric vector. Spatial resolution per band.
+
+
+
+
Value
+
+
+
Returns a structured, fully customizable meta-data table of a file
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/RStoolbox.html b/reference/RStoolbox.html
new file mode 100644
index 0000000..40aaa32
--- /dev/null
+++ b/reference/RStoolbox.html
@@ -0,0 +1,121 @@
+
+RStoolbox: A Collection of Remote Sensing Tools — RStoolbox • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
The RStoolbox package provides a set of functions which simplify performing standard remote sensing tasks in R.
+
+
+
+
+
Data Import and Export
+
+
+
+
readMeta
: import Landsat metadata from MTL or XML files
+stackMeta
: load Landsat bands based on metadata
+readSLI & writeSLI
: read and write ENVI spectral libraries
+saveRSTBX & readRSTBX
: save and re-import RStoolbox classification objects (model and map)
+readEE
: import and tidy EarthExplorer search results
+
+
+
Data Pre-Processing
+
+
+
+
radCor
: radiometric conversions and corrections. Primarily, yet not exclusively, intended for Landsat data processing. DN to radiance to reflectance conversion as well as DOS approaches
+topCor
: topographic illumination correction
+cloudMask & cloudShadowMask
: mask clouds and cloud shadows in Landsat or other imagery which comes with a thermal band
+classifyQA
: extract layers from Landsat 8 QA bands, e.g. cloud confidence
+rescaleImage
: rescale image to match min/max from another image or a specified min/max range
+normImage
: normalize imagery by centering and scaling
+histMatch
: matches the histograms of two scenes
+coregisterImages
: co-register images based on mutual information
+panSharpen
: sharpen a coarse resolution image with a high resolution image (typically panchromatic)
+
+
+
Data Analysis
+
+
+
+
spectralIndices
: calculate a set of predefined multispectral indices like NDVI
+tasseledCap
: tasseled cap transformation
+sam
: spectral angle mapper
+rasterPCA
: principal components transform for raster data
+rasterCVA
: change vector analysis
+unsuperClass
: unsupervised classification
+superClass
: supervised classification
+fCover
: fractional cover of coarse resolution imagery based on high resolution classification
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/Rplot001.png b/reference/Rplot001.png
new file mode 100644
index 0000000..aa1778b
Binary files /dev/null and b/reference/Rplot001.png differ
diff --git a/reference/Rplot002.png b/reference/Rplot002.png
new file mode 100644
index 0000000..aebc38c
Binary files /dev/null and b/reference/Rplot002.png differ
diff --git a/reference/Rplot003.png b/reference/Rplot003.png
new file mode 100644
index 0000000..d4a4445
Binary files /dev/null and b/reference/Rplot003.png differ
diff --git a/reference/Rplot004.png b/reference/Rplot004.png
new file mode 100644
index 0000000..08ab41d
Binary files /dev/null and b/reference/Rplot004.png differ
diff --git a/reference/Rplot005.png b/reference/Rplot005.png
new file mode 100644
index 0000000..0593a5f
Binary files /dev/null and b/reference/Rplot005.png differ
diff --git a/reference/Rplot006.png b/reference/Rplot006.png
new file mode 100644
index 0000000..31d7c45
Binary files /dev/null and b/reference/Rplot006.png differ
diff --git a/reference/Rplot007.png b/reference/Rplot007.png
new file mode 100644
index 0000000..d9a9117
Binary files /dev/null and b/reference/Rplot007.png differ
diff --git a/reference/Rplot008.png b/reference/Rplot008.png
new file mode 100644
index 0000000..e721f3a
Binary files /dev/null and b/reference/Rplot008.png differ
diff --git a/reference/Rplot009.png b/reference/Rplot009.png
new file mode 100644
index 0000000..99190de
Binary files /dev/null and b/reference/Rplot009.png differ
diff --git a/reference/Rplot010.png b/reference/Rplot010.png
new file mode 100644
index 0000000..e9e85c4
Binary files /dev/null and b/reference/Rplot010.png differ
diff --git a/reference/classifyQA.html b/reference/classifyQA.html
new file mode 100644
index 0000000..2195b39
--- /dev/null
+++ b/reference/classifyQA.html
@@ -0,0 +1,137 @@
+
+Classify Landsat QA bands — classifyQA • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
extracts five classes from QA band: background, cloud, cirrus, snow and water.
+
+
+
+
Usage
+
classifyQA (
+ img ,
+ type = c ( "background" , "cloud" , "cirrus" , "snow" , "water" ) ,
+ confLayers = FALSE ,
+ sensor = "OLI" ,
+ legacy = "collection1" ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Landsat 8 OLI QA band.
+
+
+type
+Character. Classes which should be returned. One or more of c("background", "cloud", "cirrus","snow", "water").
+
+
+confLayers
+Logical. Return one layer per class classified by confidence levels, i.e. cloud:low, cloud:med, cloud:high.
+
+
+sensor
+Sensor to encode. Options: c("OLI", "TIRS", "ETM+", "TM", "MSS")
.
+
+
+legacy
+Encoding systematic Options: c("collection1", "pre_collection")
. Default is "collection1" for the Landsat Collection 1 8-bit quality designations. Use "pre_collection" for imagery downloaded before the Collection 1 quality designations were introduced
+
+
+...
+further arguments passed to writeRaster
+
+
+
+
Value
+
+
+
Returns a SpatRaster with maximal five classes:
class value background 1L cloud 2L cirrus 3L snow 4L water 5L
Values outside of these classes are returned as NA.
+If confLayers = TRUE
then a RasterStack with one layer per condition (except 'background') is returned, whereby each layer contains the confidence level of the condition.
Confidence value low 1L med 2L high 3L
+
+
Details
+
By default each class is queried for *high* confidence. See encodeQA for details. To return the different confidence levels per condition use confLayers=TRUE
.
+This approach corresponds to the way LandsatLook Quality Images are produced by the USGS.
+
+
+
+
+
Examples
+
library ( terra )
+#> terra 1.7.71
+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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/cloudMask-1.png b/reference/cloudMask-1.png
new file mode 100644
index 0000000..61938a5
Binary files /dev/null and b/reference/cloudMask-1.png differ
diff --git a/reference/cloudMask-2.png b/reference/cloudMask-2.png
new file mode 100644
index 0000000..62cc744
Binary files /dev/null and b/reference/cloudMask-2.png differ
diff --git a/reference/cloudMask-3.png b/reference/cloudMask-3.png
new file mode 100644
index 0000000..0e87f30
Binary files /dev/null and b/reference/cloudMask-3.png differ
diff --git a/reference/cloudMask-4.png b/reference/cloudMask-4.png
new file mode 100644
index 0000000..c749d3e
Binary files /dev/null and b/reference/cloudMask-4.png differ
diff --git a/reference/cloudMask.html b/reference/cloudMask.html
new file mode 100644
index 0000000..4746d03
--- /dev/null
+++ b/reference/cloudMask.html
@@ -0,0 +1,187 @@
+
+Simple Cloud Detection — cloudMask • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Developed for use with Landsat data cloudMask
relies on the distinctive difference between the blue (or any other short-wave band)
+and thermal band for semi-automated creation of a cloud mask. Since it relies on thermal information it doesn't work well for sensors without
+thermal bands.
+
+
+
+
Usage
+
cloudMask (
+ x ,
+ threshold = 0.2 ,
+ blue = "B1_sre" ,
+ tir = "B6_sre" ,
+ buffer = NULL ,
+ plot = FALSE ,
+ verbose
+)
+
+
+
+
Arguments
+
x
+SpatRaster with reflectance and brightness temperature OR the mask of a previous run of cloudMask
with returnDiffLayer=TRUE
.
+
+
+threshold
+Numeric. cloud detection threshold. If not provided it will be guessed. Everything *below* this threshold will be considered a cloud pixel (unless it is removed by filtering afterwards).
+
+
+blue
+Character or integer. Bandname or number for the blue band
+
+
+tir
+Character or integer. Bandname or number for the thermal band
+
+
+buffer
+Integer. Number of pixels to use as a buffer that will be added to the identified cloud centers.
+
+
+plot
+Logical. Plots of the cloud mask for all sub-steps (sanitizing etc.) Helpful to find proper parametrization.
+
+
+verbose
+Logical. Print messages or suppress.
+
+
+
+
Value
+
+
+
Returns a SpatRaster with two layers: CMASK contains the binary cloud mask (1 = cloud, NA = not-cloud) and NDTCI contains the cloud index.
+
+
+
Note
+
Typically clouds are cold in the thermal region and have high reflectance in short wavelengths (blue). By calculating a normalized difference index between the two bands and thresholding a rough cloud mask can be obtained.
+Before calculating the spectral cloud index (let's call it Normalized Difference Thermal Cloud Index (NDTCI)) the thermal band will be matched to the same value range as the blue band. Therefore, it doesn't matter whether you
+provide DN, radiance or brightness temperature.
+
This approach to cloud masking is very simplistic. And aims only at rough removal of potentially clouded areas. Nevertheless, it is able to provide satisfactory results.
+More sophisticated approaches, including cloud cast shadow detection can be found elsewhere, e.g. fmask .
+
It can make sense to find a suitable threshold on a cropped version of the scene. Also make sure you make use of the returnDiffLayer
argument to save yourself one processing step.
+Buffering should be seen as final polishing, i.e. as long as the pure cloud centers are not detected properly, you might want to turn it off. since it takes some time to calculate.
+Once your mask detects obvious cloud pixels properly re-enable buffering for fine tuning if desired. Finally, once a suitable threshold is established re-run cloudMask on the whole scene with this threshold and go get a coffee.
+
+
+
+
+
Examples
+
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 )
+
+## 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()`).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/cloudShadowMask-1.png b/reference/cloudShadowMask-1.png
new file mode 100644
index 0000000..61938a5
Binary files /dev/null and b/reference/cloudShadowMask-1.png differ
diff --git a/reference/cloudShadowMask-2.png b/reference/cloudShadowMask-2.png
new file mode 100644
index 0000000..62cc744
Binary files /dev/null and b/reference/cloudShadowMask-2.png differ
diff --git a/reference/cloudShadowMask-3.png b/reference/cloudShadowMask-3.png
new file mode 100644
index 0000000..0e87f30
Binary files /dev/null and b/reference/cloudShadowMask-3.png differ
diff --git a/reference/cloudShadowMask-4.png b/reference/cloudShadowMask-4.png
new file mode 100644
index 0000000..9aaab54
Binary files /dev/null and b/reference/cloudShadowMask-4.png differ
diff --git a/reference/cloudShadowMask.html b/reference/cloudShadowMask.html
new file mode 100644
index 0000000..5a77cc8
--- /dev/null
+++ b/reference/cloudShadowMask.html
@@ -0,0 +1,182 @@
+
+Cloud Shadow Masking for Flat Terrain — cloudShadowMask • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Intended for interactive use, cloudShadowMask
will ask the user to select a few
+corresponding cloud/cloudShadow pixels which will be used to estimate coordinates
+for a linear cloudmask shift.
+
+
+
+
Usage
+
cloudShadowMask (
+ img ,
+ cm ,
+ nc = 5 ,
+ shiftEstimate = NULL ,
+ preciseShift = NULL ,
+ quantile = 0.2 ,
+ returnShift = FALSE
+)
+
+
+
+
Arguments
+
img
+SpatRaster containing the scene
+
+
+cm
+SpatRaster. Cloud mask (typically the result of cloudMask
)
+
+
+nc
+Integer. Number of control points. A few points (default) are fine because the final shift is estimated by coregisterImages .
+
+
+shiftEstimate
+NULL or numeric vector of length two (x,y). Estimated displacement of shadows in map units. If NULL
, the user will be asked to select control points interactively.
+
+
+preciseShift
+NULL or numeric vector of length two (x,y). Use this if cloud/cloud-shadow displacement is already known, e.g. from a previous run of cloudShadowMask
.
+
+
+quantile
+Numeric (between 0 and 1). Quantile threshold used for image co-registration. By default the 20% quantile of the total intensity (sum) of the image is used as potential shadow mask.
+
+
+returnShift
+Logical. Return a numeric vector containing the shift parameters. Useful if you estimate parameters on a subset of the image.
+
+
+
+
Value
+
+
+
Returns a RasterLayer with the cloud shadow mask (0 = shadow, NA = not-shadow).
+
+
+
Details
+
This is a very simplistic approach to cloud shadow masking (simple shift of the cloud mask). It is not image based and accuracy will suffer from clouds at different altitudes. However, just as cloudMask
+this is a quick and easy to use tool for Landsat data if you're just working on a few scenes and don't have fMask or CDR data at hand. Although for some test scenes
+it does perform surprisingly well.
+
+
+
+
+
Examples
+
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 )
+
+## 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()`).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/coregisterImages-1.png b/reference/coregisterImages-1.png
new file mode 100644
index 0000000..763c0e8
Binary files /dev/null and b/reference/coregisterImages-1.png differ
diff --git a/reference/coregisterImages-2.png b/reference/coregisterImages-2.png
new file mode 100644
index 0000000..174f032
Binary files /dev/null and b/reference/coregisterImages-2.png differ
diff --git a/reference/coregisterImages-3.png b/reference/coregisterImages-3.png
new file mode 100644
index 0000000..2b4c6a1
Binary files /dev/null and b/reference/coregisterImages-3.png differ
diff --git a/reference/coregisterImages-4.png b/reference/coregisterImages-4.png
new file mode 100644
index 0000000..e5024ef
Binary files /dev/null and b/reference/coregisterImages-4.png differ
diff --git a/reference/coregisterImages.html b/reference/coregisterImages.html
new file mode 100644
index 0000000..b670b5b
--- /dev/null
+++ b/reference/coregisterImages.html
@@ -0,0 +1,194 @@
+
+Image to Image Co-Registration based on Mutual Information — coregisterImages • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Shifts an image to match a reference image. Matching is based on maximum
+mutual information.
+
+
+
+
Usage
+
coregisterImages (
+ img ,
+ ref ,
+ shift = 3 ,
+ shiftInc = 1 ,
+ nSamples = 100 ,
+ reportStats = FALSE ,
+ verbose ,
+ nBins = 100 ,
+ master = deprecated ( ) ,
+ slave = deprecated ( ) ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Image to shift to match reference image. img
and ref
must have equal numbers of bands.
+
+
+ref
+SpatRaster. Reference image. img
and ref
must have equal numbers of bands.
+
+
+shift
+Numeric or matrix. If numeric, then shift is the maximal absolute radius (in pixels of img
resolution) which img
is shifted (seq(-shift, shift, by=shiftInc)
).
+If shift is a matrix it must have two columns (x shift and y shift), then only these shift values will be tested.
+
+
+shiftInc
+Numeric. Shift increment (in pixels, but not restricted to integer). Ignored if shift
is a matrix.
+
+
+nSamples
+Integer. Number of samples to calculate mutual information.
+
+
+reportStats
+Logical. If FALSE
it will return only the shifted images. Otherwise it will return the shifted image in a list containing stats such as mutual information per shift and joint histograms.
+
+
+verbose
+Logical. Print status messages. Overrides global RStoolbox.verbose option.
+
+
+nBins
+Integer. Number of bins to calculate joint histogram.
+
+
+master
+DEPRECATED! Argument was renamed. Please use ref
from now on.
+
+
+slave
+DEPRECATED! Argument was renamed. Please use img
from now on.
+
+
+...
+further arguments passed to writeRaster
.
+
+
+
+
Value
+
+
+
reportStats=FALSE
returns a SpatRaster (x-y shifted image).
+reportStats=TRUE
returns a list containing a data.frame with mutual information per shift ($MI), the shift of maximum MI ($bestShift),
+the joint histograms per shift in a list ($jointHist) and the shifted image ($coregImg).
+
+
+
Details
+
Currently only a simple linear x - y shift is considered and tested. No higher order shifts (e.g. rotation, non-linear transformation) are performed. This means that your imagery
+should already be properly geometrically corrected.
+
Mutual information is a similarity metric originating from information theory.
+Roughly speaking, the higher the mutual information of two data-sets, the higher is their shared information content, i.e. their similarity.
+When two images are exactly co-registered their mutual information is maximal. By trying different image shifts, we aim to find the best overlap which maximises the mutual information.
+
+
+
+
Examples
+
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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/decodeQA.html b/reference/decodeQA.html
new file mode 100644
index 0000000..94fdbea
--- /dev/null
+++ b/reference/decodeQA.html
@@ -0,0 +1,99 @@
+
+Decode QA flags to bit-words — decodeQA • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Intended for use with Landsat 16-bit QA bands. Decodes pixel quality flags from integer to bit-words.
+
+
+
+
+
+
Arguments
+
x
+Integer (16bit)
+
+
+
+
Value
+
+
+
Returns the decoded QA values from an integer
+
+
+
+
+
Examples
+
decodeQA ( 53248 )
+#> [1] "1101000000000000"
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/encodeQA.html b/reference/encodeQA.html
new file mode 100644
index 0000000..0e466bf
--- /dev/null
+++ b/reference/encodeQA.html
@@ -0,0 +1,171 @@
+
+Encode QA Conditions to Integers — encodeQA • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Intended for use with Landsat 16-bit QA bands. Converts pixel quality flags from human readable to integer, which can then be used to
+subset a QA image. Please be aware of the default settings which differ for different parameters.
+Depending on, which sensor
and legacy
is selected, some quality parameters are not used, since the sequences of available bitwise quality designations differ per sensor and collection.
+
+
+
+
Usage
+
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"
+)
+
+
+
+
Arguments
+
fill
+Designated fill. Options: c("yes", "no", "all")
.
+
+
+terrainOcclusion
+Terrain induced occlusion. Options: c("yes", "no", "all")
.
+
+
+radSaturation
+Number of bands that contain radiometric saturation. Options: c("na", "low", "med", "high", "all")
for no bands, 1-2 bands, 3-4 bands, 5 or more bands contain saturation.
+
+
+cloudMask
+Cloud mask. Options: c("yes", "no", "all")
.
+
+
+cloud
+Cloud confidence. Options: c("na", "low", "med", "high", "all")
.
+
+
+cloudShadow
+Cloud shadow confidence. Options: c("yes", "no", "all")
.
+
+
+snow
+Snow / ice confidence. Options: c("na", "low", "med", "high", "all")
.
+
+
+cirrus
+Cirrus confidence. Options: c("na", "low", "med", "high", "all")
.
+
+
+droppedPixel
+Dropped pixel. Options: c("yes", "no", "all")
.
+
+
+water
+Water confidence. Options: c("na", "low", "med", "high", "all")
.
+
+
+droppedFrame
+Dropped frame. Options: c("yes", "no", "all")
.
+
+
+sensor
+Sensor to encode. Options: c("OLI", "TIRS", "ETM+", "TM", "MSS")
.
+
+
+legacy
+Encoding systematic Options: c("collection1", "pre_collection")
. Default is "collection1" for the Landsat Collection 1 8-bit quality designations. Use "pre_collection" for imagery downloaded before the Collection 1 quality designations were introduced
+
+
+
+
Value
+
+
+
Returns the Integer value for the QA values
+
+
+
Note
+
Only currently populated bits are available as arguments.
+
+
+
+
+
Examples
+
encodeQA ( snow = "low" , cirrus = c ( "med" , "high" ) , cloud = "high" )
+#> [1] 23136 23264 23392 23520 23152 23280 23408 23536
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/estimateHaze.html b/reference/estimateHaze.html
new file mode 100644
index 0000000..01d8d4a
--- /dev/null
+++ b/reference/estimateHaze.html
@@ -0,0 +1,145 @@
+
+Estimate Image Haze for Dark Object Subtraction (DOS) — estimateHaze • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
estimates the digital number (DN) pixel value of *dark* objects for the visible wavelength range.
+
+
+
+
Usage
+
estimateHaze (
+ x ,
+ hazeBands ,
+ darkProp = 0.01 ,
+ maxSlope = TRUE ,
+ plot = FALSE ,
+ returnTables = FALSE
+)
+
+
+
+
Arguments
+
x
+SpatRaster or a previous result from estimateHaze
with returnTables = TRUE
from which to estimate haze
+
+
+hazeBands
+Integer or Character. Band number or bandname from which to estimate atmospheric haze (optional if x contains only one layer)
+
+
+darkProp
+Numeric. Proportion of pixels estimated to be dark.
+
+
+maxSlope
+Logical. Use darkProp
only as an upper boundary and search for the DN of maximum slope in the histogram below this value.
+
+
+plot
+Logical. Option to display histograms and haze values
+
+
+returnTables
+Logical. Option to return the frequency table per layer. Only takes effect if x is a SpatRaster. If x is a result of estimateHaze tables will always be returned.
+
+
+
+
Value
+
+
+
If returnTables is FALSE (default). Then a vector of length(hazeBands) containing the estimated haze DNs will be returned.
+If returnTables is TRUE a list with two components will be returned. The list element 'SHV' contains the haze values, while 'table'
+contains another list with the sampled frequency tables. The latter can be re-used to try different darkProp thresholds without having to sample
+the raster again.
+
+
+
Details
+
It is assumed that any radiation originating from *dark* pixels is due to atmospheric haze and
+not the reflectance of the surface itself (the surface is dark, i.e. it has a reflectance close to zero).
+Hence, the haze values are estimates of path radiance, which can be subtracted in a dark object subtraction (DOS) procedure (see radCor
)
+
Atmospheric haze affects almost exclusively the visible wavelength range. Therefore, typically, you'd only want to estimate haze in blue, green and red bands, occasionally also in the nir band.
+
+
+
+
Examples
+
## 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
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/fCover-1.png b/reference/fCover-1.png
new file mode 100644
index 0000000..ebc6abf
Binary files /dev/null and b/reference/fCover-1.png differ
diff --git a/reference/fCover.html b/reference/fCover.html
new file mode 100644
index 0000000..c2208ab
--- /dev/null
+++ b/reference/fCover.html
@@ -0,0 +1,240 @@
+
+Fractional Cover Analysis — fCover • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
fCover takes a classified high resolution image, e.g. vegetation and non-vegetation based on Landsat and calculates cover fractions for
+pixels of a coarser resolution, e.g. MODIS.
+
+
+
+
Usage
+
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 ,
+ ...
+)
+
+
+
+
Arguments
+
classImage
+high resolution SpatRaster containing a landcover classification, e.g. as obtained by superClass .
+
+
+predImage
+coarse resolution SpatRaster for which fractional cover will be estimated.
+
+
+nSamples
+Integer. Number of pixels to sample from predImage to train the regression model
+
+
+classes
+Integer. Classes for which fractional cover should be estimated (one or more).
+
+
+maxNA
+Numeric. Maximal proportion of NAs allowed in training pixels.
+
+
+clamp
+Logical. Enforce results to stay within [0,1] interval. Values <0 are reset to 0 and values >1 to 1.
+
+
+model
+Character. Which model to fit for image regression. See train for options. Defaults to randomForest ('rf')
+
+
+tuneLength
+Integer. Number of levels for each tuning parameters that should be generated by train. See Details and train
.
+
+
+trControl
+trainControl
object, specifying resampling, validation etc.
+
+
+method
+DEPREACTED! in favor of trControl=trainControl(method="cv")
Resampling method for parameter tuning. Defaults to 10 fold cross-validation. See trainControl
for options.
+
+
+filename
+Character. Filename of the output raster file (optional).
+
+
+overwrite
+Logical. if TRUE
, filename
will be overwritten.
+
+
+verbose
+Logical. Print progress information.
+
+
+...
+further arguments to be passed to writeRaster
+
+
+
+
Value
+
+
+
Returns a list with two elements: models contains the fitted models evaluated in tenfold cross-validation (caret train objects);
+fCover contains a SpatRaster with a fractional cover layer for each requested class.
+
+
+
Details
+
fCover gets the pixel values in a high resolution classified image that correspond to
+randomly selected moderate resolution pixels and then calculates the percent of
+the classified image pixels that represent your cover type of interest. In other words, if
+your high resolution image has a pixel size of 1m and your moderate resolution image has a
+pixel size of 30m the sampling process would take a block of 900 of the 1m resolution pixels
+that correspond to a single 30m pixel and calculate the percentage of the 1m pixels that
+are forest. For example, if there were 600 forest pixels and 300 non-forest pixels the value
+given for the output pixel would be 0.67 since 67
+
fCover relies on the train() function from the caret package which provides access to a huge number of classifiers.
+Please see the available options at train . The default classifier (randomForest) we chose has been shown
+to provide very good results in image regression and hence it is recomended you start with this one. If you choose a different
+classifier, make sure it can run in regression mode.
+
Many models require tuning of certain parameters. Again, this is handled by train from the caret package.
+With the tuneLength argument you can specify how many different values of each tuning parameter should be tested. The Random Forest
+algorithm for example can be tuned by varying the mtry parameter. Hence, by specifying tuneLength = 10, ten different levels
+of mtry will be tested in a cross-validation scheme and the best-performing value will be chosen for the final model.
+
+
If the total no-data values for a block of high resolution pixels is greater than maxNA then
+it will not be included in the training data set since there is too much missing data to provide
+a reliable cover percentage. If the no-data proporton is less then maxNA the no-data pixels are removed
+from the total number of pixels when calculating the percent cover.
+
+
+
+
+
Examples
+
# \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 ) )
+# }
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/figures/logo.png b/reference/figures/logo.png
new file mode 100644
index 0000000..f3ee20b
Binary files /dev/null and b/reference/figures/logo.png differ
diff --git a/reference/fortifySpatRaster.html b/reference/fortifySpatRaster.html
new file mode 100644
index 0000000..15fbf6e
--- /dev/null
+++ b/reference/fortifySpatRaster.html
@@ -0,0 +1,106 @@
+
+Fortify method for classes from the terra package. — fortifySpatRaster • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Fortify method for classes from the terra package.
+
+
+
+
Usage
+
fortifySpatRaster ( x , maxpixels = 50000 )
+
+
+
+
Arguments
+
x
+SpatRaster
object to convert into a dataframe.
+
+
+maxpixels
+Integer. Maximum number of pixels to sample
+
+
+
+
Value
+
+
+
Returns a data.frame with coordinates (x,y) and corresponding raster values.
+
+
+
+
Examples
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/getMeta.html b/reference/getMeta.html
new file mode 100644
index 0000000..bcf5e77
--- /dev/null
+++ b/reference/getMeta.html
@@ -0,0 +1,150 @@
+
+Extract bandwise information from ImageMetaData — getMeta • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
This is an accessor function to quickly access information stored in ImageMetaData, e.g. scale factor per band.
+Intended for use with imagery which was imported using stackMeta. Will return parameters using the actual band order in img.
+
+
+
+
Usage
+
getMeta ( img , metaData , what )
+
+
+
+
Arguments
+
img
+SpatRaster or character vector with band names.
+
+
+metaData
+ImageMetaData or path to meta data file.
+
+
+what
+Character. Parameter to extract. Either data descriptors, or conversion parameters (see Details for options)
+
+
+
+
Value
+
+
+
If what
is one of c('CALRAD', 'CALBT', 'CALREF')
a data.frame is returned with bands in rows (order corresponding to img
band order).
+Otherwise a named numeric vector with the corresponding parameter is returned (layernames as names).
+
+
+
Details
+
Possible metadata parameters (what
argument):
+
Data descriptors
'FILES' 'QUANTITY' 'CATEGORY' 'NA_VALUE' 'SATURATE_VALUE' 'SCALE_FACTOR' 'DATA_TYPE' 'SPATIAL_RESOLUTION'
Conversion parameters
'CALRAD' Conversion parameters from DN to radiance 'CALBT' Conversion parameters from radiance to brightness temperature 'CALREF' Conversion parameters from DN to reflectance (Landsat 8 only)
+
+
+
Examples
+
## 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"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/getValidation.html b/reference/getValidation.html
new file mode 100644
index 0000000..18f0144
--- /dev/null
+++ b/reference/getValidation.html
@@ -0,0 +1,142 @@
+
+Extract validation results from superClass objects — getValidation • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Extract validation results from superClass objects
+
+
+
+
Usage
+
getValidation ( x , from = "testset" , metrics = "overall" )
+
+
+
+
Arguments
+
x
+superClass object or caret::confusionMatrix
+
+
+from
+Character. 'testset' extracts the results from independent validation with testset. 'cv' extracts cross-validation results.
+
+
+metrics
+Character. Only relevant in classification mode (ignored for regression models).
+Select 'overall' for overall accuracy metrics, 'classwise' for classwise metrics,
+'confmat' for the confusion matrix itself and 'caret' to return the whole caret::confusionMatrix object.
+
+
+
+
Value
+
+
+
Returns a data.frame with validation results.
+If metrics = 'confmat' or 'caret' will return a table or the full caret::confusionMatrix object, respectively.
+
+
+
+
Examples
+
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_lsat.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
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/ggR-1.png b/reference/ggR-1.png
new file mode 100644
index 0000000..7532cc0
Binary files /dev/null and b/reference/ggR-1.png differ
diff --git a/reference/ggR-10.png b/reference/ggR-10.png
new file mode 100644
index 0000000..6979ff8
Binary files /dev/null and b/reference/ggR-10.png differ
diff --git a/reference/ggR-2.png b/reference/ggR-2.png
new file mode 100644
index 0000000..84eb3e2
Binary files /dev/null and b/reference/ggR-2.png differ
diff --git a/reference/ggR-3.png b/reference/ggR-3.png
new file mode 100644
index 0000000..b78a697
Binary files /dev/null and b/reference/ggR-3.png differ
diff --git a/reference/ggR-4.png b/reference/ggR-4.png
new file mode 100644
index 0000000..604f8ab
Binary files /dev/null and b/reference/ggR-4.png differ
diff --git a/reference/ggR-5.png b/reference/ggR-5.png
new file mode 100644
index 0000000..401a0e6
Binary files /dev/null and b/reference/ggR-5.png differ
diff --git a/reference/ggR-6.png b/reference/ggR-6.png
new file mode 100644
index 0000000..77d4a14
Binary files /dev/null and b/reference/ggR-6.png differ
diff --git a/reference/ggR-7.png b/reference/ggR-7.png
new file mode 100644
index 0000000..84b7d10
Binary files /dev/null and b/reference/ggR-7.png differ
diff --git a/reference/ggR-8.png b/reference/ggR-8.png
new file mode 100644
index 0000000..7f36901
Binary files /dev/null and b/reference/ggR-8.png differ
diff --git a/reference/ggR-9.png b/reference/ggR-9.png
new file mode 100644
index 0000000..f928565
Binary files /dev/null and b/reference/ggR-9.png differ
diff --git a/reference/ggR.html b/reference/ggR.html
new file mode 100644
index 0000000..65ccce5
--- /dev/null
+++ b/reference/ggR.html
@@ -0,0 +1,243 @@
+
+Plot RasterLayers in ggplot with greyscale — ggR • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Plot single layer imagery in grey-scale. Can be used with a SpatRaster.
+
+
+
+
Usage
+
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
+)
+
+
+
+
Arguments
+
img
+SpatRaster
+
+
+layer
+Character or numeric. Layername or number. Can be more than one layer, in which case each layer is plotted in a subplot.
+
+
+maxpixels
+Integer. Maximal number of pixels to sample.
+
+
+alpha
+Numeric. Transparency (0-1).
+
+
+hue
+Numeric. Hue value for color calculation [0,1] (see hsv
). Change if you need anything else than greyscale. Only effective if sat > 0
.
+
+
+sat
+Numeric. Saturation value for color calculation [0,1] (see hsv
). Change if you need anything else than greyscale.
+
+
+stretch
+Character. Either 'none', 'lin', 'hist', 'sqrt' or 'log' for no stretch, linear, histogram, square-root or logarithmic stretch.
+
+
+quantiles
+Numeric vector with two elements. Min and max quantiles to stretch to. Defaults to 2% stretch, i.e. c(0.02,0.98).
+
+
+ext
+Extent object to crop the image
+
+
+coord_equal
+Logical. Force addition of coord_equal, i.e. aspect ratio of 1:1. Typically useful for remote sensing data (depending on your projection), hence it defaults to TRUE.
+Note however, that this does not apply if (ggLayer=FALSE
).
+
+
+ggLayer
+Logical. Return only a ggplot layer which must be added to an existing ggplot. If FALSE
s stand-alone ggplot will be returned.
+
+
+ggObj
+Logical. Return a stand-alone ggplot object (TRUE) or just the data.frame with values and colors
+
+
+geom_raster
+Logical. If FALSE
uses annotation_raster (good to keep aestetic mappings free). If TRUE
uses geom_raster
(and aes(fill)
). See Details.
+
+
+forceCat
+Logical. If TRUE
the raster values will be forced to be categorical (will be converted to factor if needed).
+
+
+
+
Value
+
+
+
ggObj = TRUE
:ggplot2 plot ggLayer = TRUE
:ggplot2 layer to be combined with an existing ggplot2 ggObj = FALSE
:data.frame in long format suitable for plotting with ggplot2,
+ includes the pixel values and the calculated colors
+
+
Details
+
When img
contains factor values and annotation=TRUE
, the raster values will automatically be converted
+to numeric in order to proceed with the brightness calculation.
+
The geom_raster argument switches from the default use of annotation_raster to geom_raster. The difference between the two is that geom_raster performs
+a meaningful mapping from pixel values to fill colour, while annotation_raster is simply adding a picture to your plot. In practice this means that whenever you
+need a legend for your raster you should use geom_raster = TRUE
. This also allows you to specify and modify the fill scale manually.
+The advantage of using annotation_raster (geom_raster = TRUE
) is that you can still use the scale_fill* for another variable. For example you could add polygons and
+map a value to their fill colour. For more details on the theory behind aestetic mapping have a look at the ggplot2 manuals.
+
+
+
+
+
Examples
+
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" )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/ggRGB-1.png b/reference/ggRGB-1.png
new file mode 100644
index 0000000..aad5c03
Binary files /dev/null and b/reference/ggRGB-1.png differ
diff --git a/reference/ggRGB-2.png b/reference/ggRGB-2.png
new file mode 100644
index 0000000..4c46113
Binary files /dev/null and b/reference/ggRGB-2.png differ
diff --git a/reference/ggRGB-3.png b/reference/ggRGB-3.png
new file mode 100644
index 0000000..836df45
Binary files /dev/null and b/reference/ggRGB-3.png differ
diff --git a/reference/ggRGB-4.png b/reference/ggRGB-4.png
new file mode 100644
index 0000000..ccfaafa
Binary files /dev/null and b/reference/ggRGB-4.png differ
diff --git a/reference/ggRGB-5.png b/reference/ggRGB-5.png
new file mode 100644
index 0000000..567b7e4
Binary files /dev/null and b/reference/ggRGB-5.png differ
diff --git a/reference/ggRGB.html b/reference/ggRGB.html
new file mode 100644
index 0000000..775d0f3
--- /dev/null
+++ b/reference/ggRGB.html
@@ -0,0 +1,225 @@
+
+Create ggplot2 Raster Plots with RGB from 3 RasterLayers — ggRGB • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculates RGB color composite raster for plotting with ggplot2. Optional values for clipping and and stretching can be used to enhance the imagery.
+
+
+
+
Usage
+
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
+)
+
+
+
+
Arguments
+
img
+SpatRaster
+
+
+r
+Integer or character. Red layer in x. Can be set to NULL
, in which case the red channel will be set to zero.
+
+
+g
+Integer or character. Green layer in x. Can be set to NULL
, in which case the green channel will be set to zero.
+
+
+b
+Integer or character. Blue layer in x. Can be set to NULL
, in which case the blue channel will be set to zero.
+
+
+scale
+Numeric. Maximum possible pixel value (optional). Defaults to 255 or to the maximum value of x if that is larger than 255
+
+
+maxpixels
+Integer. Maximal number of pixels used for plotting.
+
+
+stretch
+Character. Either 'none', 'lin', 'hist', 'sqrt' or 'log' for no stretch, linear, histogram, square-root or logarithmic stretch.
+
+
+ext
+Extent or SpatExtent object to crop the image
+
+
+limits
+Vector or matrix. Can be used to reduce the range of values. Either a vector of two values for all bands (c(min, max))
+or a 3x2 matrix with min and max values (columns) for each layer (rows).
+
+
+clipValues
+Matrix, numeric vector, string or NA. Values to reset out of range (out of limits
) values to.
+By default ('limits') values are reset to limits
. A single value (e.g. NA) will be recycled to all lower/higher clippings,
+A vector of length two (c(min,max)) can be used to specify lower and higher replace values, applied to all bands.
+A two column matrix (typically with three rows) can be used to fully control lower and upper clipping values differently for each band.
+
+
+quantiles
+Numeric vector with two elements. Min and max quantiles to stretch. Defaults to 2% stretch, i.e. c(0.02,0.98).
+
+
+ggObj
+Logical. If TRUE
a ggplot2 object is returned. If FALSE
a data.frame with coordinates and color will be returned.
+
+
+ggLayer
+Logical. If TRUE
a ggplot2 layer is returned. This is useful if you want to add it to an existing ggplot2 object.
+Note that if TRUE
& annotate = FALSE
you have to add a scale_fill_identity() manually in your call to ggplot().
+
+
+alpha
+Numeric. Transparency (0-1).
+
+
+coord_equal
+Logical. Force addition of coord_equal, i.e. aspect ratio of 1:1. Typically useful for remote sensing data (depending on your projection), hence it defaults to TRUE.
+Note howver, that this does not apply if (ggLayer=FALSE
).
+
+
+geom_raster
+Logical. If FALSE
annotation_raster is used, otherwise geom_raster()+scale_fill_identity is used.
+Note that you can't use scale_fill* in addition to the latter, because it already requires scale_fill_identity().
+
+
+nullValue
+Numeric. Intensity value used for NULL layers in color compositing. E.g. set g=NULL and fix green value at 0.5 (defaults to 0).
+
+
+
+
Value
+
+
+
ggObj = TRUE
:ggplot2 plot ggLayer = TRUE
:ggplot2 layer to be combined with an existing ggplot2 ggObj = FALSE
:data.frame in long format suitable for plotting with ggplot2, includes the pixel values and the calculated colors
+
+
Details
+
Functionality is based on plotRGB
from the raster package.
+
+
+
+
+
Examples
+
+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 ) )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/histMatch-1.png b/reference/histMatch-1.png
new file mode 100644
index 0000000..b2d6da4
Binary files /dev/null and b/reference/histMatch-1.png differ
diff --git a/reference/histMatch-2.png b/reference/histMatch-2.png
new file mode 100644
index 0000000..80d388d
Binary files /dev/null and b/reference/histMatch-2.png differ
diff --git a/reference/histMatch-3.png b/reference/histMatch-3.png
new file mode 100644
index 0000000..23525a2
Binary files /dev/null and b/reference/histMatch-3.png differ
diff --git a/reference/histMatch.html b/reference/histMatch.html
new file mode 100644
index 0000000..865b2f2
--- /dev/null
+++ b/reference/histMatch.html
@@ -0,0 +1,189 @@
+
+Image to Image Contrast Matching — histMatch • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Performs image to image contrast adjustments based on histogram matching using empirical cumulative
+ distribution functions from both images.
+
+
+
+
Usage
+
histMatch (
+ x ,
+ ref ,
+ xmask = NULL ,
+ refmask = NULL ,
+ nSamples = 1e+05 ,
+ intersectOnly = TRUE ,
+ paired = TRUE ,
+ forceInteger = FALSE ,
+ returnFunctions = FALSE ,
+ ...
+)
+
+
+
+
Arguments
+
x
+SpatRaster. Source raster which is to be modified.
+
+
+ref
+SpatRaster. Reference raster, to which x will be matched.
+
+
+xmask
+RasterLayer or SpatRaster. Mask layer for x
to exclude pixels which might distort the histogram, i.e. are not present in ref
. Any NA pixel in xmask
will be ignored (maskvalue = NA
).
+
+
+refmask
+RasterLayer or SpatRaster. Mask layer for ref
. Any NA pixel in refmask
will be ignored (maskvalue = NA
).
+
+
+nSamples
+Integer. Number of random samples from each image to build the histograms.
+
+
+intersectOnly
+Logical. If TRUE
sampling will only take place in the overlap extent of the two rasters. Otherwise the full rasters will be used for sampling.
+
+
+paired
+Logical. If TRUE
the corresponding pixels will be used in the overlap.
+
+
+forceInteger
+Logical. Force integer output.
+
+
+returnFunctions
+Logical. If TRUE
the matching functions will be returned instead of applying them to x
.
+
+
+...
+Further arguments to be passed to writeRaster .
+
+
+
+
Value
+
+
+
A SpatRaster of x
adjusted to the histogram of ref
. If returnFunctions = TRUE
a list of functions (one for each layer) will be returned instead.
+
+
+
Note
+
x
and ref
must have the same number of layers.
+
+
+
References
+
Richards and Jia: Remote Sensing Digital Image Analysis. Springer, Berlin, Heidelberg, Germany, 439pp.
+
+
+
+
Examples
+
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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/index.html b/reference/index.html
new file mode 100644
index 0000000..75a64a5
--- /dev/null
+++ b/reference/index.html
@@ -0,0 +1,306 @@
+
+Function reference • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
All functions
+
+
+
+
+
+
+
+
+
+
+
+ ImageMetaData()
+
+ ImageMetaData Class
+
+
+ RStoolbox
+
+ RStoolbox: A Collection of Remote Sensing Tools
+
+
+ classifyQA()
+
+ Classify Landsat QA bands
+
+
+ cloudMask()
+
+ Simple Cloud Detection
+
+
+ cloudShadowMask()
+
+ Cloud Shadow Masking for Flat Terrain
+
+
+ coregisterImages()
+
+ Image to Image Co-Registration based on Mutual Information
+
+
+ decodeQA()
+
+ Decode QA flags to bit-words
+
+
+ encodeQA()
+
+ Encode QA Conditions to Integers
+
+
+ estimateHaze()
+
+ Estimate Image Haze for Dark Object Subtraction (DOS)
+
+
+ fCover()
+
+ Fractional Cover Analysis
+
+
+ fortifySpatRaster()
+
+ Fortify method for classes from the terra package.
+
+
+ getMeta()
+
+ Extract bandwise information from ImageMetaData
+
+
+ getValidation()
+
+ Extract validation results from superClass objects
+
+
+ ggR()
+
+ Plot RasterLayers in ggplot with greyscale
+
+
+ ggRGB()
+
+ Create ggplot2 Raster Plots with RGB from 3 RasterLayers
+
+
+ histMatch()
+
+ Image to Image Contrast Matching
+
+
+ lsat
+
+ Landsat 5TM Example Data
+
+
+ mesma()
+
+ Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing)
+
+
+ normImage()
+
+ Normalize Raster Images: Center and Scale
+
+
+ oneHotEncode()
+
+ One-hot encode a raster or vector
+
+
+ panSharpen()
+
+ Pan Sharpen Imagery / Image Fusion
+
+
+ pifMatch()
+
+ Pseudo-Invariant Features based Image Matching
+
+
+ predict(<unsuperClass> )
+
+ Predict a raster map based on a unsuperClass model fit.
+
+
+ radCor()
+
+ Radiometric Calibration and Correction
+
+
+ rasterCVA()
+
+ Change Vector Analysis
+
+
+ rasterEntropy()
+
+ Multi-layer Pixel Entropy
+
+
+ rasterPCA()
+
+ Principal Component Analysis for Rasters
+
+
+ readEE()
+
+ Tidy import tool for EarthExplorer .csv export files
+
+
+ readMeta()
+
+ Read Landsat MTL metadata files
+
+
+ readSLI()
+
+ Read ENVI spectral libraries
+
+
+ rescaleImage()
+
+ Linear Image Rescaling
+
+
+ rlogo
+
+ Rlogo as SpatRaster
+
+
+ rsOpts()
+
+ Set global options for RStoolbox
+
+
+ sam()
+
+ Spectral Angle Mapper
+
+
+ saveRSTBX()
readRSTBX()
+
+ Save and Read RStoolbox Classification Results
+
+
+ sen2
+
+ Sentinel 2 MSI L2A Scene
+
+
+ spectralIndices()
+
+ Spectral Indices
+
+
+ srtm
+
+ SRTM Digital Elevation Model
+
+
+ srtm_sen2
+
+ SRTM scene for the sen2 exemplary scene
+
+
+ stackMeta()
+
+ Import separate Landsat files into single stack
+
+
+ superClass()
+
+ Supervised Classification
+
+
+ tasseledCap()
+
+ Tasseled Cap Transformation
+
+
+ topCor()
+
+ Topographic Illumination Correction
+
+
+ unsuperClass()
+
+ Unsupervised Classification
+
+
+ validateMap()
+
+ Map accuracy assessment
+
+
+ writeSLI()
+
+ Write ENVI spectral libraries
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/lsat-1.png b/reference/lsat-1.png
new file mode 100644
index 0000000..41b44b0
Binary files /dev/null and b/reference/lsat-1.png differ
diff --git a/reference/lsat.html b/reference/lsat.html
new file mode 100644
index 0000000..e1c25b7
--- /dev/null
+++ b/reference/lsat.html
@@ -0,0 +1,86 @@
+
+Landsat 5TM Example Data — lsat • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Subset of Landsat 5 TM Scene: LT52240631988227CUB02
+Contains all seven bands in DN format.
+
+
+
+
+
+
+
Examples
+
ggRGB ( lsat , stretch = "sqrt" )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/mesma-1.png b/reference/mesma-1.png
new file mode 100644
index 0000000..22a8f7d
Binary files /dev/null and b/reference/mesma-1.png differ
diff --git a/reference/mesma-2.png b/reference/mesma-2.png
new file mode 100644
index 0000000..bc59937
Binary files /dev/null and b/reference/mesma-2.png differ
diff --git a/reference/mesma-3.png b/reference/mesma-3.png
new file mode 100644
index 0000000..58f3067
Binary files /dev/null and b/reference/mesma-3.png differ
diff --git a/reference/mesma.html b/reference/mesma.html
new file mode 100644
index 0000000..a117982
--- /dev/null
+++ b/reference/mesma.html
@@ -0,0 +1,192 @@
+
+Multiple Endmember Spectral Mixture Analysis (Spectral Unmixing) — mesma • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
mesma
performs a spectral mixture anlylsis (SMA) or multiple endmember spectral mixture analysis (MESMA) on a multiband raster image.
+
+
+
+
Usage
+
mesma (
+ img ,
+ em ,
+ method = "NNLS" ,
+ iterate = 400 ,
+ tolerance = 1e-08 ,
+ n_models = 5 ,
+ sum_to_one = TRUE ,
+ ... ,
+ verbose
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Remote sensing imagery (usually hyperspectral).
+
+
+em
+Matrix or data.frame with spectral endmembers. Columns represent the spectral bands (i.e. columns correspond to number of bands in img
). Rows represent either a single endmember per class (SMA) or multiple endmembers per class (MESMA), if a column with name class
is present, containing the class name each endmember belongs to, e.g. "water" or "land". See details below. Number of rows needs to be > 1.
+
+
+method
+Character. Select an unmixing method. Currently, only "NNLS" is implemented. Default is "NNLS".
+
+
+iterate
+Integer. Set maximum iteration per pixel. Processing time could increase the more iterations are made possible. Default is 400.
+
+
+tolerance
+Numeric. Tolerance limit representing a nearly zero minimal number. Default is 1e-8.
+
+
+n_models
+Logical. Only applies if em
contains column class
. Defines how many endmember combinations should be picked. Maximum is the minimum number of endmembers of a class. Defaults to 5.
+
+
+sum_to_one
+Logical. Defines whether a sum-to-one constraint should be applied so that probabilities of endmember classes sum to one (a constraint not covered by NNLS) to be interpretable as fractions. Defaults to TRUE
. To get actual NNLS results, change to FALSE
.
+
+
+...
+further arguments passed to writeRaster .
+
+
+verbose
+Logical. Prints progress messages during execution.
+
+
+
+
Value
+
+
+
SpatRaster. The object will contain one band per class, with each value representing the estimated probability of the respective endmember class per pixel, and an RMSE band. If sum_to_one
is TRUE
(default), values of the class bands can be interpreted as fractions per endmember class (0 to 1).
+
+
+
Details
+
Argument em
determines whether an SMA (each row representing a single endmember per class) or a MESMA (multiple endmembers per class differentiate using the class
column) is computed.
+If multiple endmembers per class are provided, mesma
will compute a number of SMA (determined by argument n_models
) for multiple endmember combinations drawn from em
and will select the best fit per pixel based on the lowest RMSE, based on the MESMA approach proposed by Roberts et al. (1998).
+
+
+
Note
+
Depending on iterate
and tolerance
settings and the selected endmembers, the sum of estimated probabilities per pixel varies around 1. NNLS does not account for a sum-to-one constraint. Use sum_to_one
to sum to one post-NNLS.
+
To achieve best results, it is recommended to adjust n_models
in accordance to the number of endemembers per class provided through em
so that as many endmember combinations as possible (with each endmember being used once) are computed. The more models are being calculated, the more processing and memory recourses are needed.
+
+
+
References
+
Franc, V., Hlaváč, V., & Navara, M. (2005). Sequential coordinate-wise algorithm for the non-negative least squares problem. In: International Conference on Computer Analysis of Images and Patterns (pp. 407-414). Berlin, Heidelberg.
+
Roberts, D. A., Gardner, M., Church, R., Ustin, S., Scheer, G., & Green, R. O. (1998). Mapping chaparral in the Santa Monica Mountains using multiple endmember spectral mixture models. Remote sensing of environment, 65(3), 267-279.
+
+
+
Author
+
Jakob Schwalb-Willmann
+
+
+
+
Examples
+
+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':
+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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/normImage-1.png b/reference/normImage-1.png
new file mode 100644
index 0000000..5c0105b
Binary files /dev/null and b/reference/normImage-1.png differ
diff --git a/reference/normImage.html b/reference/normImage.html
new file mode 100644
index 0000000..aa99a09
--- /dev/null
+++ b/reference/normImage.html
@@ -0,0 +1,111 @@
+
+Normalize Raster Images: Center and Scale — normImage • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
For each pixel subtracts the mean of the raster layer and optionally divide by its standard deviation.
+
+
+
+
Usage
+
normImage ( img , norm = TRUE , ... )
+
+
+
+
Arguments
+
img
+SpatRaster. Image to transform. Transformation will be performed separately for each layer.
+
+
+norm
+Logical. Perform normalization (scaling) in addition to centering, i.e. divide by standard deviation.
+
+
+...
+further arguments passed to writeRaster .
+
+
+
+
Value
+
+
+
Returns a SpatRaster with the same number layers as input layers with each layer being centered and optionally normalized.
+
+
+
+
Examples
+
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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/oneHotEncode.html b/reference/oneHotEncode.html
new file mode 100644
index 0000000..0335255
--- /dev/null
+++ b/reference/oneHotEncode.html
@@ -0,0 +1,132 @@
+
+One-hot encode a raster or vector — oneHotEncode • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Splits a categorical raster layer (or a vector) into a multilayer raster (or matrix).
+
+
+
+
Usage
+
oneHotEncode ( img , classes , background = 0 , foreground = 1 , na.rm = FALSE , ... )
+
+
+
+
Arguments
+
img
+SpatRaster or integer/numeric vector containing multiple classes
+
+
+classes
+integer: vector of classes which should be extracted
+
+
+background
+integer: background value (default = 0)
+
+
+foreground
+integer: foreground value (default = 1)
+
+
+na.rm
+logical: if TRUE
, NA
s will be coerced to the background
value.
+
+
+...
+further arguments passed to writeRaster . Ignored if img is not a SpatRaster, but a numeric/integer vector or matrix
+
+
+
+
Value
+
+
+
A SpatRaster with as many layers as there are classes.
+Pixels matching the class of interest are set to 1, backround values by default are set to 0 (see background argument)
+
+
+
+
Examples
+
# \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
+# }
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/panSharpen-1.png b/reference/panSharpen-1.png
new file mode 100644
index 0000000..a429bf1
Binary files /dev/null and b/reference/panSharpen-1.png differ
diff --git a/reference/panSharpen-2.png b/reference/panSharpen-2.png
new file mode 100644
index 0000000..ef64ed5
Binary files /dev/null and b/reference/panSharpen-2.png differ
diff --git a/reference/panSharpen-3.png b/reference/panSharpen-3.png
new file mode 100644
index 0000000..9cefb69
Binary files /dev/null and b/reference/panSharpen-3.png differ
diff --git a/reference/panSharpen.html b/reference/panSharpen.html
new file mode 100644
index 0000000..cc0d79d
--- /dev/null
+++ b/reference/panSharpen.html
@@ -0,0 +1,163 @@
+
+Pan Sharpen Imagery / Image Fusion — panSharpen • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
provides different methods for pan sharpening a coarse resolution (typically multispectral) image with
+a higher reolution panchromatic image. Values of the pan-chromatic and multispectral images must be of the same scale, (e.g. from 0:1, or all DNs from 0:255)
+
+
+
+
Usage
+
panSharpen ( img , pan , r , g , b , pc = 1 , method = "brovey" , norm = TRUE )
+
+
+
+
Arguments
+
img
+SpatRaster. Coarse resolution multispectral image
+
+
+pan
+SpatRaster. High resolution image, typically panchromatic.
+
+
+r
+Character or Integer. Red band in img
. Only relevant if method!='pca'
+
+
+g
+Character or Integer. Green band in img
. Only relevant if method!='pca'
+
+
+b
+Character or Integer. Blue band in img
. Only relevant if method!='pca'
+
+
+pc
+Integer. Only relevant if method = 'pca'
. Which principal component to replace. Usually this should be the first component (default). Only if the first component is dominated by something else than brightness it might be worth a try to use the second component.
+
+
+method
+Character. Choose method from c("pca", "ihs", "brovey").
+
+
+norm
+Logical. Rescale pan image to match the 1st PC component. Only relevant if method = 'pca'
. If TRUE
only min and max are matched to the 1st PC. If FALSE
pan will be histogram matched to the 1st PC.
+
+
+
+
Value
+
+
+
pan-sharpened SpatRaster
+
+
+
Details
+
Pan sharpening options:
method='pca'
: Performs a pca using rasterPCA . The first component is then swapped for the pan band an the PCA is rotated backwards.
+method='ihs'
: Performs a color space transform to Intensity-Hue-Saturation space, swaps intensity for the histogram matched pan and does the backwards transformation.
+method='brovey'
: Performs Brovey reweighting. Pan and img must be at the same value scale (e.g. 0:1, or 0:255) otherwise you'll end up with psychodelic colors.
+
+
+
+
Examples
+
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]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/pifMatch-1.png b/reference/pifMatch-1.png
new file mode 100644
index 0000000..e4631bf
Binary files /dev/null and b/reference/pifMatch-1.png differ
diff --git a/reference/pifMatch-2.png b/reference/pifMatch-2.png
new file mode 100644
index 0000000..9d4a4ae
Binary files /dev/null and b/reference/pifMatch-2.png differ
diff --git a/reference/pifMatch-3.png b/reference/pifMatch-3.png
new file mode 100644
index 0000000..f713bfc
Binary files /dev/null and b/reference/pifMatch-3.png differ
diff --git a/reference/pifMatch.html b/reference/pifMatch.html
new file mode 100644
index 0000000..7f8713d
--- /dev/null
+++ b/reference/pifMatch.html
@@ -0,0 +1,187 @@
+
+Pseudo-Invariant Features based Image Matching — pifMatch • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Match one scene to another based on linear regression of pseudo-invariant features (PIF).
+
+
+
+
Usage
+
pifMatch (
+ img ,
+ ref ,
+ method = "cor" ,
+ quantile = 0.95 ,
+ returnPifMap = TRUE ,
+ returnSimMap = TRUE ,
+ returnModels = FALSE
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Image to be adjusted.
+
+
+ref
+SpatRaster. Reference image.
+
+
+method
+Method to calculate pixel similarity. Options: euclidean distance ('ed'), spectral angle ('sam') or pearson correlation coefficient ('cor').
+
+
+quantile
+Numeric. Threshold quantile used to identify PIFs
+
+
+returnPifMap
+Logical. Return a binary raster map ot pixels which were identified as pesudo-invariant features.
+
+
+returnSimMap
+Logical. Return the similarity map as well
+
+
+returnModels
+Logical. Return the linear models along with the adjusted image.
+
+
+
+
Value
+
+
+
Returns a List with the adjusted image and intermediate products (if requested).
img
: the adjusted image
+simMap
: pixel-wise similarity map (if returnSimMap = TRUE
)
+pifMap
: binary map of pixels selected as pseudo-invariant features (if returnPifMap = TRUE
)
+models
: list of linear models; one per layer (if returnModels = TRUE
)
+
+
+
Details
+
The function consists of three main steps:
+First, it calculates pixel-wise similarity between the two rasters and identifies pseudo-invariant pixels based on
+a similarity threshold.
+In the second step the values of the pseudo-invariant pixels are regressed against each other in a linear model for each layer.
+Finally the linear models are applied to all pixels in the img
, thereby matching it to the reference scene.
+
Pixel-wise similarity can be calculated using one of three methods: euclidean distance (method = "ed"
), spectral angle ("sam"
) or pearsons correlation coefficient ("cor"
).
+The threshold is defined as a similarity quantile. Setting quantile=0.95
will select all pixels with a similarity above the 95% quantile as pseudo-invariant features.
+
Model fitting is performed with simple linear models (lm
); fitting one model per layer.
+
+
+
+
Examples
+
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, Adjusted R-squared: 0.976
+#> F-statistic: 1.811e+05 on 1 and 4447 DF, p-value: < 2.2e-16
+#>
+# }
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/pipe.html b/reference/pipe.html
new file mode 100644
index 0000000..6c435c8
--- /dev/null
+++ b/reference/pipe.html
@@ -0,0 +1,93 @@
+
+Pipe operator — %>% • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
See magrittr::%>%
for details.
+
+
+
+
+
+
Arguments
+
lhs
+A value or the magrittr placeholder.
+
+
+rhs
+A function call using the magrittr semantics.
+
+
+
+
Value
+
+
+
The result of calling `rhs(lhs)`.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/predict.unsuperClass.html b/reference/predict.unsuperClass.html
new file mode 100644
index 0000000..5157cca
--- /dev/null
+++ b/reference/predict.unsuperClass.html
@@ -0,0 +1,116 @@
+
+Predict a raster map based on a unsuperClass model fit. — predict.unsuperClass • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
applies a kmeans cluster model to all pixels of a raster.
+Useful if you want to apply a kmeans model of scene A to scene B.
+
+
+
+
Usage
+
# S3 method for unsuperClass
+predict ( object , img , output = "classes" , ... )
+
+
+
+
Arguments
+
object
+unsuperClass object
+
+
+img
+Raster object. Layernames must correspond to layernames used to train the superClass model, i.e. layernames in the original raster image.
+
+
+output
+Character. Either 'classes' (kmeans class; default) or 'distances' (euclidean distance to each cluster center).
+
+
+...
+further arguments to be passed to writeRaster , e.g. filename
+
+
+
+
Value
+
+
+
Returns a raster with the K-means distances base on your object passed in the arguments.
+
+
+
+
Examples
+
## Load training data
+
+## Perform unsupervised classification
+uc <- unsuperClass ( rlogo , nClasses = 10 )
+
+## Apply the model to another raster
+map <- predict ( uc , rlogo )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/radCor.html b/reference/radCor.html
new file mode 100644
index 0000000..31b8d4e
--- /dev/null
+++ b/reference/radCor.html
@@ -0,0 +1,189 @@
+
+Radiometric Calibration and Correction — radCor • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Implements several different methods for radiometric calibration and correction of Landsat data.
+You can either specify a metadata file, or supply all neccesary values manually.
+With proper parametrization apref and sdos should work for other sensors as well.
+
+
+
+
Usage
+
radCor (
+ img ,
+ metaData ,
+ method = "apref" ,
+ bandSet = "full" ,
+ hazeValues ,
+ hazeBands ,
+ atmosphere ,
+ darkProp = 0.01 ,
+ clamp = TRUE ,
+ verbose
+)
+
+
+
+
Arguments
+
img
+SpatRaster
+
+
+metaData
+object of class ImageMetaData or a path to the meta data (MTL) file.
+
+
+method
+Radiometric conversion/correction method to be used. There are currently four methods available (see Details):
+"rad", "apref", "sdos", "dos", "costz".
+
+
+bandSet
+Numeric or character. original Landsat band numbers or names in the form of ("B1", "B2" etc). If set to 'full' all bands in the solar (optical) region will be processed.
+
+
+hazeValues
+Numeric. Either a vector with dark DNs per hazeBand
(method = 'sdos'); possibly estimated using estimateHaze .
+Or the 'starting haze value' (DN) for the relative scattering models in method = 'dos' or 'costz'
. If not provided, hazeValues will be estimated in an automated fashion for all hazeBands
.
+Argument only applies to methods 'sdos', 'dos' and 'costz'.
+
+
+hazeBands
+Character or integer. Bands corresponding to hazeValues
(method = 'sdos') or band to select starting haze value from ('dos' or 'costz').
+
+
+atmosphere
+Character. Atmospheric characteristics. Will be estimated if not expicilty provided. Must be one of "veryClear", "clear", "moderate", "hazy"
or "veryHazy"
.
+
+
+darkProp
+Numeric. Estimated proportion of dark pixels in the scene. Used only for automatic guessing of hazeValues (typically one would choose 1 or 2%).
+
+
+clamp
+Logical. Enforce valid value range. By default reflectance will be forced to stay within [0,1] and radiance >= 0 by replacing invalid values with the correspinding boundary, e.g. -0.1 will become 0.
+
+
+verbose
+Logical. Print status information.
+
+
+
+
Value
+
+
+
SpatRaster with top-of-atmosphere radiance (\(W/(m^2 * srad * \mu m)\)), at-satellite brightness temperature (K),
+top-of-atmosphere reflectance (unitless) corrected for the sun angle or at-surface reflectance (unitless).
+
+
+
Details
+
The atmospheric correction methods (sdos, dos and costz) apply to the optical (solar) region of the spectrum and do not affect the thermal band.
+
Dark object subtraction approaches rely on the estimation of atmospheric haze based on *dark* pixels. Dark pixels are assumed to have zero reflectance, hence the name.
+It is then assumed further that any radiation originating from such *dark* pixels is due to atmospheric haze and
+not the reflectance of the surface itself.
+
The folloiwing methods
are available:
rad Radiance apref Apparent reflectance (top-of-atmosphere reflectance) dos Dark object subtratction following Chavez (1989) costz Dark object subtraction following Chavez (1996) sdos Simple dark object subtraction. Classical DOS, Lhaze must be estimated for each band separately.
If either "dos" or "costz" are selected, radCor will use the atmospheric haze decay model described by Chavez (1989).
+Depending on the atmosphere
the following coefficients are used:
veryClear \(\lambda^{-4.0}\) clear \(\lambda^{-2.0}\) moderate \(\lambda^{-1.0}\) hazy \(\lambda^{-0.7}\) veryHazy \(\lambda^{-0.5}\)
For Landsat 8, no values for extra-terrestrial irradiation (esun) are provided by NASA. These are, however, neccessary for DOS-based approaches.
+Therefore, these values were derived from a standard reference spectrum published by Thuillier et al. (2003) using the Landsat 8 OLI spectral response functions
+(for details, see http://bleutner.github.io/RStoolbox/r/2016/01/26/estimating-landsat-8-esun-values ).
+
The implemented sun-earth distances neglect the earth's eccentricity. Instead we use a 100 year daily average (1979-2070).
+
+
+
Note
+
This was originally a fork of randcorr() function in the landsat package. This version works on SpatRasters and hence is suitable for large rasters.
+
+
+
References
+
S. Goslee (2011): Analyzing Remote Sensing Data in R: The landsat Package. Journal of Statistical Software 43(4).
+
G. Thuillier et al. (2003) THE SOLAR SPECTRAL IRRADIANCE FROM 200 TO 2400 nm AS MEASURED BY THE SOLSPEC SPECTROMETER FROM THE ATLAS AND EURECA MISSIONS. Solar Physics 214(1): 1-22 (
+
+
+
+
Examples
+
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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rasterCVA.html b/reference/rasterCVA.html
new file mode 100644
index 0000000..22f93fd
--- /dev/null
+++ b/reference/rasterCVA.html
@@ -0,0 +1,135 @@
+
+Change Vector Analysis — rasterCVA • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculates angle and magnitude of change vectors.
+Dimensionality is limited to two bands per image.
+
+
+
+
Usage
+
rasterCVA ( x , y , tmf = NULL , nct = NULL , ... )
+
+
+
+
Arguments
+
x
+SpatRaster with two layers. This will be the reference/origin for the change calculations. Both rasters (y and y) need to correspond to each other, i.e. same resolution, extent and origin.
+
+
+y
+SpatRaster with two layers. Both rasters (y and y) need to correspond to each other, i.e. same resolution, extent and origin.
+
+
+tmf
+Numeric. Threshold median factor (optional). Used to calculate a threshold magnitude for which pixels are considered stable, i.e. no change. Calculated as tmf * mean(magnitude[magnitude > 0])
.
+
+
+nct
+Numeric. No-change threshold (optional). Alternative to tmf
. Sets an absolute threshold. Change magnitudes below nct
are considered stable and set to NA.
+
+
+...
+further arguments passed to writeRaster
+
+
+
+
Value
+
+
+
Returns a SpatRaster with two layers: change vector angle and change vector magnitude
+
+
+
Details
+
Change Vector Analysis (CVA) is used to identify spectral changes between two identical scenes which were acquired at different times.
+CVA is limited to two bands per image. For each pixel it calculates the change vector in the two-dimensional spectral space.
+For example for a given pixel in image A and B for the red and nir band the change vector is calculated for the coordinate pairs: (red_A | nir_A) and (red_B | nir_B).
+
The coordinate system is defined by the order of the input bands: the first band defines the x-axis and the second band the y-axis, respectively.
+ Angles are returned *in degree* beginning with 0 degrees pointing 'north', i.e. the y-axis, i.e. the second band.
+
+
+
+
Examples
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rasterEntropy-1.png b/reference/rasterEntropy-1.png
new file mode 100644
index 0000000..94b3e7e
Binary files /dev/null and b/reference/rasterEntropy-1.png differ
diff --git a/reference/rasterEntropy.html b/reference/rasterEntropy.html
new file mode 100644
index 0000000..b6827ee
--- /dev/null
+++ b/reference/rasterEntropy.html
@@ -0,0 +1,107 @@
+
+Multi-layer Pixel Entropy — rasterEntropy • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Shannon entropy is calculated for each pixel based on it's layer values.
+To be used with categorical / integer valued rasters.
+
+
+
+
+
+
Arguments
+
img
+SpatRaster
+
+
+...
+additional arguments passed to writeRaster
+
+
+
+
Value
+
+
+
SpatRaster "entropy"
+
+
+
Details
+
Entropy is calculated as -sum(p log(p)); p being the class frequency per pixel.
+
+
+
+
Examples
+
re <- rasterEntropy ( rlogo )
+ggR ( re , geom_raster = TRUE )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rasterPCA-1.png b/reference/rasterPCA-1.png
new file mode 100644
index 0000000..aad5c03
Binary files /dev/null and b/reference/rasterPCA-1.png differ
diff --git a/reference/rasterPCA-2.png b/reference/rasterPCA-2.png
new file mode 100644
index 0000000..29a1ea9
Binary files /dev/null and b/reference/rasterPCA-2.png differ
diff --git a/reference/rasterPCA-3.png b/reference/rasterPCA-3.png
new file mode 100644
index 0000000..317cc1d
Binary files /dev/null and b/reference/rasterPCA-3.png differ
diff --git a/reference/rasterPCA.html b/reference/rasterPCA.html
new file mode 100644
index 0000000..92fc84e
--- /dev/null
+++ b/reference/rasterPCA.html
@@ -0,0 +1,197 @@
+
+Principal Component Analysis for Rasters — rasterPCA • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculates R-mode PCA for SpatRasters and returns a SpatRaster with multiple layers of PCA scores.
+
+
+
+
Usage
+
rasterPCA (
+ img ,
+ nSamples = NULL ,
+ nComp = nlyr ( img ) ,
+ spca = FALSE ,
+ maskCheck = TRUE ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster.
+
+
+nSamples
+Integer or NULL. Number of pixels to sample for PCA fitting. If NULL, all pixels will be used.
+
+
+nComp
+Integer. Number of PCA components to return.
+
+
+spca
+Logical. If TRUE
, perform standardized PCA. Corresponds to centered and scaled input image. This is usually beneficial for equal weighting of all layers. (FALSE
by default)
+
+
+maskCheck
+Logical. Masks all pixels which have at least one NA (default TRUE is reccomended but introduces a slow-down, see Details when it is wise to disable maskCheck).
+Takes effect only if nSamples is NULL.
+
+
+...
+further arguments to be passed to writeRaster , e.g. filename.
+
+
+
+
Value
+
+
+
Returns a named list containing the PCA model object ($model) and a SpatRaster with the principal component layers ($object).
+
+
+
Details
+
Internally rasterPCA relies on the use of princomp (R-mode PCA). If nSamples is given the PCA will be calculated
+based on a random sample of pixels and then predicted for the full raster. If nSamples is NULL then the covariance matrix will be calculated
+first and will then be used to calculate princomp and predict the full raster. The latter is more precise, since it considers all pixels,
+however, it may be slower than calculating the PCA only on a subset of pixels.
+
Pixels with missing values in one or more bands will be set to NA. The built-in check for such pixels can lead to a slow-down of rasterPCA.
+However, if you make sure or know beforehand that all pixels have either only valid values or only NAs throughout all layers you can disable this check
+by setting maskCheck=FALSE which speeds up the computation.
+
Standardised PCA (SPCA) can be useful if imagery or bands of different dynamic ranges are combined. SPC uses the correlation matrix instead of the covariance matrix, which
+has the same effect as using normalised bands of unit variance.
+
+
+
+
Examples
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/readEE-1.png b/reference/readEE-1.png
new file mode 100644
index 0000000..aad2e0e
Binary files /dev/null and b/reference/readEE-1.png differ
diff --git a/reference/readEE.html b/reference/readEE.html
new file mode 100644
index 0000000..0a5f7fd
--- /dev/null
+++ b/reference/readEE.html
@@ -0,0 +1,147 @@
+
+Tidy import tool for EarthExplorer .csv export files — readEE • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Imports and tidies CSV files exported from EarthExplorer into data.frames and annotates missing fields.
+
+
+
+
+
+
Arguments
+
x
+Character, Character or list. One or more paths to EarthExplorer export files.
+
+
+
+
Value
+
+
+
data.frame
+
+
+
Details
+
The EarthExplorer CSV file can be produced from the search results page. Above the results click on 'export results' and select 'comma (,) delimited'.
+
Note that only a subset of columns is imported which was deemed interesting. Please contact the maintainer if you think an omited column should be included.
+
+
+
+
Examples
+
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)" )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/readMeta.html b/reference/readMeta.html
new file mode 100644
index 0000000..35aee1d
--- /dev/null
+++ b/reference/readMeta.html
@@ -0,0 +1,164 @@
+
+Read Landsat MTL metadata files — readMeta • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Reads metadata and deals with legacy versions of Landsat metadata files and where possible adds missing information (radiometric gain and offset, earth-sun distance).
+
+
+
+
Usage
+
readMeta ( file , raw = FALSE )
+
+
+
+
Arguments
+
file
+path to Landsat MTL file (...MTL.txt)
+
+
+raw
+Logical. If TRUE
the full raw metadata will be returned as a list. if FALSE
(the default) all important metadata are homogenized into a standard format (ImageMetaData) and some information is added.
+
+
+
+
Value
+
+
+
Object of class ImageMetaData
+
+
+
+
Examples
+
## 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):
+#> dn -> radiance (toa)
+#> dn -> brightness temperature (toa)
+#>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/readSLI-1.png b/reference/readSLI-1.png
new file mode 100644
index 0000000..7e70d32
Binary files /dev/null and b/reference/readSLI-1.png differ
diff --git a/reference/readSLI.html b/reference/readSLI.html
new file mode 100644
index 0000000..5bdc641
--- /dev/null
+++ b/reference/readSLI.html
@@ -0,0 +1,122 @@
+
+Read ENVI spectral libraries — readSLI • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
read/write support for ENVI spectral libraries
+
+
+
+
+
+
Arguments
+
path
+Path to spectral library file with ending .sli.
+
+
+
+
Value
+
+
+
The spectral libraries are read into a data.frame. The first column contains the wavelengths and the remaining columns contain the spectra.
+
+
+
Details
+
ENVI spectral libraries consist of a binary data file (.sli) and a corresponding header (.hdr, or .sli.hdr) file.
+
+
+
+
+
Examples
+
+## 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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rescaleImage.html b/reference/rescaleImage.html
new file mode 100644
index 0000000..1c47bdb
--- /dev/null
+++ b/reference/rescaleImage.html
@@ -0,0 +1,172 @@
+
+Linear Image Rescaling — rescaleImage • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
performs linear shifts of value ranges either to match min/max of another image (y
)
+or to any other min and max value (ymin
and ymax
).
+
+
+
+
Usage
+
rescaleImage ( x , y , xmin , xmax , ymin , ymax , forceMinMax = FALSE , ... )
+
+
+
+
Arguments
+
x
+SpatRaster or numeric vector. Image to normalise.
+
+
+y
+SpatRaster or numeric vector. Reference image. Optional. Used to extract min and max values if ymin or ymax are missing.
+
+
+xmin
+Numeric. Min value of x. Either a single value or one value per layer in x. If xmin is not provided it will be extracted from x.
+
+
+xmax
+Numeric. Max value of x. Either a single value or one value per layer in x. If xmax is not provided it will be extracted from x.
+
+
+ymin
+Numeric. Min value of y. Either a single value or one value per layer in x. If ymin is not provided it will be extracted from y.
+
+
+ymax
+Numeric. Max value of y. Either a single value or one value per layer in x. If ymax is not provided it will be extracted from y.
+
+
+forceMinMax
+Logical. Forces update of min and max data slots in x or y.
+
+
+...
+additional arguments passed to terra::writeRaster()
+
+
+
+
Value
+
+
+
Returns a SpatRaster of the same dimensions as the input raster x
but shifted and stretched to the new limits.
+
+
+
Details
+
Providing xmin
and xmax
values manually can be useful if the raster contains a variable of a known, fixed value range,
+e.g. NDVI from -1 to 1 but the actual pixel values don't encompass this entire range.
+By providing xmin = -1
and xmax = 1
the values can be rescaled to any other range,
+e.g. 1 to 100 while comparability to other rescaled NDVI scenes is retained.
+
+
+
+
+
Examples
+
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, ...
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rlogo-1.png b/reference/rlogo-1.png
new file mode 100644
index 0000000..aad5c03
Binary files /dev/null and b/reference/rlogo-1.png differ
diff --git a/reference/rlogo.html b/reference/rlogo.html
new file mode 100644
index 0000000..f64f52f
--- /dev/null
+++ b/reference/rlogo.html
@@ -0,0 +1,83 @@
+
+Rlogo as SpatRaster — rlogo • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Tiny example of raster data used to run examples.
+
+
+
+
+
+
+
Examples
+
ggRGB ( rlogo ,r = 1 ,g = 2 ,b = 3 )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/rsOpts.html b/reference/rsOpts.html
new file mode 100644
index 0000000..7d8ed01
--- /dev/null
+++ b/reference/rsOpts.html
@@ -0,0 +1,95 @@
+
+Set global options for RStoolbox — rsOpts • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
shortcut to options(RStoolbox.*)
+
+
+
+
+
+
Arguments
+
verbose
+Logical. If TRUE
many functions will print status messages about the current processing step. By default verbose mode is disabled.
+
+
+
+
Value
+
+
+
No return, just a setter for the verbosiness of the RStoolbox package
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/sam-1.png b/reference/sam-1.png
new file mode 100644
index 0000000..f168554
Binary files /dev/null and b/reference/sam-1.png differ
diff --git a/reference/sam-2.png b/reference/sam-2.png
new file mode 100644
index 0000000..2edd63e
Binary files /dev/null and b/reference/sam-2.png differ
diff --git a/reference/sam.html b/reference/sam.html
new file mode 100644
index 0000000..7ce1862
--- /dev/null
+++ b/reference/sam.html
@@ -0,0 +1,132 @@
+
+Spectral Angle Mapper — sam • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculates the angle in spectral space between pixels and a set of reference spectra (endmembers) for image classification based on spectral similarity.
+
+
+
+
Usage
+
sam ( img , em , angles = FALSE , ... )
+
+
+
+
Arguments
+
img
+SpatRaster. Remote sensing imagery.
+
+
+em
+Matrix or data.frame with endmembers. Each row should contain the endmember spectrum of a class, i.e. columns correspond to bands in img
. It is reccomended to set the rownames to class names.
+
+
+angles
+Logical. If TRUE
a RasterBrick containing each one layer per endmember will be returned containing the spectral angles.
+
+
+...
+further arguments to be passed to writeRaster
+
+
+
+
Value
+
+
+
SpatRaster
+If angles = FALSE
a single Layer will be returned in which each pixel is assigned to the closest endmember class (integer pixel values correspond to row order of em
.
+
+
+
Details
+
For each pixel the spectral angle mapper calculates the angle between the vector defined by the pixel values and each endmember vector. The result of this is
+one raster layer for each endmember containing the spectral angle. The smaller the spectral angle the more similar a pixel is to a given endmember class.
+In a second step one can the go ahead an enforce thresholds of maximum angles or simply classify each pixel to the most similar endmember.
+
+
+
+
Examples
+
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" ) )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/saveRSTBX.html b/reference/saveRSTBX.html
new file mode 100644
index 0000000..f1ff542
--- /dev/null
+++ b/reference/saveRSTBX.html
@@ -0,0 +1,143 @@
+
+Save and Read RStoolbox Classification Results — saveRSTBX • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Saves objects of classes unsuperClass, superClass, rasterPCA and fCover to
+file. Useful to archive the fitted models.
+
+
+
+
Usage
+
saveRSTBX ( x , filename , format = "raster" , ... )
+
+readRSTBX ( filename )
+
+
+
+
Arguments
+
x
+RStoolbox object of classes c("fCover", "rasterPCA", "superClass", "unsuperClass")
+
+
+filename
+Character. Path and filename. Any file extension will be ignored.
+
+
+format
+Character. Driver to use for the raster file
+
+
+...
+further arguments passed to writeRaster
+
+
+
+
Value
+
+
+
The output of writeRSTBX will be at least two files written to disk:
+a) an .rds file containing the object itself and
+b) the raster file (depending on the driver you choose this can be more than two files).
+
+
+
+
Note
+
All files must be kept in the same directory to read the full object back into R
+by means of readRSTBX. You can move them to another location but you'll have to move *all* of them
+(just like you would with Shapefiles). In case the raster file(s) is missing, readRSTBX will still
+return the object but the raster will be missing.
+
writeRSTBX and readRSTBX are convenience wrappers around saveRDS, readRDS. This means
+you can read all files created this way also with base functionality as long as you don't move your files.
+This is because x$map is a SpatRaster object and hence contains only a static link to the file on disk.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/sen2-1.png b/reference/sen2-1.png
new file mode 100644
index 0000000..ba815eb
Binary files /dev/null and b/reference/sen2-1.png differ
diff --git a/reference/sen2.html b/reference/sen2.html
new file mode 100644
index 0000000..85195d1
--- /dev/null
+++ b/reference/sen2.html
@@ -0,0 +1,83 @@
+
+Sentinel 2 MSI L2A Scene — sen2 • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Contains all 13 bands in already converted spectral reflectances
+
+
+
+
+
+
+
Examples
+
ggRGB ( sen2 , r= 4 , g= 3 , b= 2 , stretch = "lin" )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/spectralIndices-1.png b/reference/spectralIndices-1.png
new file mode 100644
index 0000000..9e8dd59
Binary files /dev/null and b/reference/spectralIndices-1.png differ
diff --git a/reference/spectralIndices-2.png b/reference/spectralIndices-2.png
new file mode 100644
index 0000000..d6a2420
Binary files /dev/null and b/reference/spectralIndices-2.png differ
diff --git a/reference/spectralIndices.html b/reference/spectralIndices.html
new file mode 100644
index 0000000..fbc2cd8
--- /dev/null
+++ b/reference/spectralIndices.html
@@ -0,0 +1,236 @@
+
+Spectral Indices — spectralIndices • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculate a suite of multispectral indices such as NDVI, SAVI etc. in an efficient way.
+
+
+
+
Usage
+
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 ) ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Typically remote sensing imagery, which is to be classified.
+
+
+blue
+Character or integer. Blue band.
+
+
+green
+Character or integer. Green band.
+
+
+red
+Character or integer. Red band.
+
+
+nir
+Character or integer. Near-infrared band (700-1100nm).
+
+
+redEdge1
+Character or integer. Red-edge band (705nm)
+
+
+redEdge2
+Character or integer. Red-edge band (740nm)
+
+
+redEdge3
+Character or integer. Red-edge band (783nm)
+
+
+swir1
+not used
+
+
+swir2
+Character or integer. Short-wave-infrared band (1400-1800nm).
+
+
+swir3
+Character or integer. Short-wave-infrared band (2000-2500nm).
+
+
+scaleFactor
+Numeric. Scale factor for the conversion of scaled reflectances to [0,1] value range (applied as reflectance/scaleFactor) Neccesary for calculating EVI/EVI2 with scaled reflectance values.
+
+
+skipRefCheck
+Logical. When EVI/EVI2 is to be calculated there is a rough heuristic check, whether the data are inside [0,1]+/-0.5 (after applying a potential scaleFactor
).
+If there are invalid reflectances, e.g. clouds with reflectance > 1 this check will result in a false positive and skip EVI calculation. Use this argument to skip this check in such cases *iff* you are sure the data and scaleFactor are valid.
+
+
+indices
+Character. One or more spectral indices to calculate (see Details). By default (NULL) all implemented indices given the spectral bands which are provided will be calculated.
+
+
+index
+Character. Alias for indices
.
+
+
+maskLayer
+RasterLayer or SpatRaster containing a mask, e.g. clouds, for which pixels are set to NA. Alternatively a layername or -number can be provided if the mask is part of img
.
+
+
+maskValue
+Integer. Pixel value in maskLayer
which should be masked in output, i.e. will be set to NA
in all calculated indices.
+
+
+coefs
+List of coefficients (see Details).
+
+
+...
+further arguments such as filename etc. passed to writeRaster
+
+
+
+
Value
+
+
+
SpatRaster
+
+
+
Details
+
spectralIndices
calculates all indices in one go in C++, which is more efficient than calculating each index separately (for large rasters).
+By default all indices which can be calculated given the specified indices will be calculated. If you don't want all indices, use the indices
argument to specify exactly which indices are to be calculated.
+See the table bellow for index names and required bands.
+
Index values outside the valid value ranges (if such a range exists) will be set to NA. For example a pixel with NDVI > 1 will be set to NA.
+
+
+
+
+
+
+
Index Description Source Bands Formula CLG Green-band Chlorophyll Index Gitelson2003 redEdge3, green
\(redEdge3/green - 1\) CLRE Red-edge-band Chlorophyll Index Gitelson2003 redEdge3, redEdge1
\(redEdge3/redEdge1 - 1\) CTVI Corrected Transformed Vegetation Index Perry1984 red, nir
\((NDVI + 0.5)/sqrt(abs(NDVI + 0.5))\) DVI Difference Vegetation Index Richardson1977 red, nir
\(s * nir - red\) EVI Enhanced Vegetation Index Huete1999 red, nir, blue
\(G * ((nir - red)/(nir + C1 * red - C2 * blue + L_evi))\) EVI2 Two-band Enhanced Vegetation Index Jiang 2008 red, nir
\(G * (nir - red)/(nir + 2.4 * red + 1)\) GEMI Global Environmental Monitoring Index Pinty1992 red, nir
\((((nir^2 - red^2) * 2 + (nir * 1.5) + (red * 0.5))/(nir + red + 0.5)) * (1 - ((((nir^2 - red^2) * 2 + (nir * 1.5) + (red * 0.5))/(nir + red + 0.5)) * 0.25)) - ((red - 0.125)/(1 - red))\) GNDVI Green Normalised Difference Vegetation Index Gitelson1998 green, nir
\((nir - green)/(nir + green)\) KNDVI Kernel Normalised Difference Vegetation Index Camps-Valls2021 red, nir
\(tanh(((nir - red)/(nir + red)))^2\) MCARI Modified Chlorophyll Absorption Ratio Index Daughtery2000 green, red, redEdge1
\(((redEdge1 - red) - (redEdge1 - green)) * (redEdge1/red)\) MNDWI Modified Normalised Difference Water Index Xu2006 green, swir2
\((green - swir2)/(green + swir2)\) MSAVI Modified Soil Adjusted Vegetation Index Qi1994 red, nir
\(nir + 0.5 - (0.5 * sqrt((2 * nir + 1)^2 - 8 * (nir - (2 * red))))\) MSAVI2 Modified Soil Adjusted Vegetation Index 2 Qi1994 red, nir
\((2 * (nir + 1) - sqrt((2 * nir + 1)^2 - 8 * (nir - red)))/2\) MTCI MERIS Terrestrial Chlorophyll Index DashAndCurran2004 red, redEdge1, redEdge2
\((redEdge2 - redEdge1)/(redEdge1 - red)\) NBRI Normalised Burn Ratio Index Garcia1991 nir, swir3
\((nir - swir3)/(nir + swir3)\) NDREI1 Normalised Difference Red Edge Index 1 GitelsonAndMerzlyak1994 redEdge2, redEdge1
\((redEdge2 - redEdge1)/(redEdge2 + redEdge1)\) NDREI2 Normalised Difference Red Edge Index 2 Barnes2000 redEdge3, redEdge1
\((redEdge3 - redEdge1)/(redEdge3 + redEdge1)\) NDVI Normalised Difference Vegetation Index Rouse1974 red, nir
\((nir - red)/(nir + red)\) NDVIC Corrected Normalised Difference Vegetation Index Nemani1993 red, nir, swir2
\((nir - red)/(nir + red) * (1 - ((swir2 - swir2ccc)/(swir2coc - swir2ccc)))\) NDWI Normalised Difference Water Index McFeeters1996 green, nir
\((green - nir)/(green + nir)\) NDWI2 Normalised Difference Water Index Gao1996 nir, swir2
\((nir - swir2)/(nir + swir2)\) NRVI Normalised Ratio Vegetation Index Baret1991 red, nir
\((red/nir - 1)/(red/nir + 1)\) REIP Red Edge Inflection Point GuyotAndBarnet1988 red, redEdge1, redEdge2, redEdge3
\(0.705 + 0.35 * ((red + redEdge3)/(2 - redEdge1))/(redEdge2 - redEdge1)\) RVI Ratio Vegetation Index red, nir
\(red/nir\) SATVI Soil Adjusted Total Vegetation Index Marsett2006 red, swir2, swir3
\((swir2 - red)/(swir2 + red + L) * (1 + L) - (swir3/2)\) SAVI Soil Adjusted Vegetation Index Huete1988 red, nir
\((nir - red) * (1 + L)/(nir + red + L)\) SLAVI Specific Leaf Area Vegetation Index Lymburger2000 red, nir, swir2
\(nir/(red + swir2)\) SR Simple Ratio Vegetation Index Birth1968 red, nir
\(nir/red\) TTVI Thiam's Transformed Vegetation Index Thiam1997 red, nir
\(sqrt(abs((nir - red)/(nir + red) + 0.5))\) TVI Transformed Vegetation Index Deering1975 red, nir
\(sqrt((nir - red)/(nir + red) + 0.5)\) WDVI Weighted Difference Vegetation Index Richardson1977 red, nir
\(nir - s * red\)
Some indices require additional parameters, such as the slope of the soil line which are specified via a list to the coefs
argument.
+Although the defaults are sensible values, values like the soil brightnes factor L
for SAVI should be adapted depending on the characteristics of the scene.
+The coefficients are:
Coefficient Description Affected Indices s
slope of the soil line DVI, WDVI L_evi, C1, C2, G
various EVI L
soil brightness factor SAVI, SATVI swir2ccc
minimum swir2 value (completely closed forest canopy) NDVIC swir2coc
maximum swir2 value (completely open canopy) NDVIC
The wavelength band names are defined following Schowengertd 2007, p10.
+The last column shows exemplarily which Landsat 5 TM bands correspond to which wavelength range definition.
Band Description Wavl_min Wavl_max Landsat5_Band Sentinel2_Band vis visible 400 680 1,2,3 2,3,4 red-edge1 red-edge1 680 720 - 5 red-edge2 red-edge2 720 760 - 6 red-edge3 red-edge3 760 800 - 7 nir near infra-red 800 1100 4 8/8a swir1 short-wave infra-red 1100 1351 - 9,10 swir2 short-wave infra-red 1400 1800 5 11 swir3 short-wave infra-red 2000 2500 7 12 mir1 mid-wave infra-red 3000 4000 - - mir2 mid-wave infra-red 45000 5000 - - tir1 thermal infra-red 8000 9500 - - tir2 thermal infra-red 10000 140000 6
+
+
+
Examples
+
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" )
+#> 08:20:41 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn
+#> 08:20:41 | Thermal bands to convert to brightness temperature: B6_dn
+#> 08:20:41 | Processing thermal band(s)
+#> 08:20:41 | Processing radiance / reflectance
+
+SI <- spectralIndices ( lsat_ref , red = "B3_tre" , nir = "B4_tre" )
+plot ( SI )
+
+# }
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/srtm-1.png b/reference/srtm-1.png
new file mode 100644
index 0000000..e357544
Binary files /dev/null and b/reference/srtm-1.png differ
diff --git a/reference/srtm.html b/reference/srtm.html
new file mode 100644
index 0000000..e644eb5
--- /dev/null
+++ b/reference/srtm.html
@@ -0,0 +1,83 @@
+
+SRTM Digital Elevation Model — srtm • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
DEM for the Landsat example area taken from SRTM v3 tile: s04_w050_1arc_v3.tif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/srtm_sen2-1.png b/reference/srtm_sen2-1.png
new file mode 100644
index 0000000..f45d3f4
Binary files /dev/null and b/reference/srtm_sen2-1.png differ
diff --git a/reference/srtm_sen2.html b/reference/srtm_sen2.html
new file mode 100644
index 0000000..883fac3
--- /dev/null
+++ b/reference/srtm_sen2.html
@@ -0,0 +1,83 @@
+
+SRTM scene for the sen2 exemplary scene — srtm_sen2 • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
DEM for the Sentinel 2 example area taken from SRTM v4
+
+
+
+
+
+
+
Examples
+
ggR ( srtm_sen2 )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/stackMeta.html b/reference/stackMeta.html
new file mode 100644
index 0000000..3d5f7d7
--- /dev/null
+++ b/reference/stackMeta.html
@@ -0,0 +1,195 @@
+
+Import separate Landsat files into single stack — stackMeta • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Reads Landsat MTL or XML metadata files and loads single Landsat Tiffs into a rasterStack.
+Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m.
+
+
+
+
Usage
+
stackMeta ( file , quantity = "all" , category = "image" , allResolutions = FALSE )
+
+
+
+
Arguments
+
file
+Character. Path to Landsat MTL metadata (*_MTL.txt) file or an Landsat CDR xml metadata file (*.xml).
+
+
+quantity
+Character vector. Which quantity should be returned. Options: digital numbers ('dn'), top of atmosphere reflectance ('tre'), at surface reflectance ('sre'), brightness temperature ('bt'), spectral index ('index'), all quantities ('all').
+
+
+category
+Character vector. Which category of data to return. Options 'image': image data, 'pan': panchromatic image, 'index': multiband indices, 'qa' quality flag bands, 'all': all categories.
+
+
+allResolutions
+Logical. if TRUE
a list will be returned with length = unique spatial resolutions.
+This argument was introduced to maintain backward compatibility and will be switched to TRUE in an upcoming release. Please base all new code on terra.
+
+
+
+
Value
+
+
+
Returns one single SpatRaster comprising all requested bands.
+If allResolutions = TRUE
*and* there are different resolution layers (e.g. a 15m panchromatic band along wit 30m imagery) a list of RasterStacks will be returned.
+
+
+
Note
+
Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m. Use the allResolutions argument to import all layers.
+Note that nowadays the USGS uses cubic convolution to resample the TIR bands to 30m resolution.
+
+
+
+
Examples
+
## 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):
+#> dn -> radiance (toa)
+#> dn -> 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, ...
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/superClass-1.png b/reference/superClass-1.png
new file mode 100644
index 0000000..07b5244
Binary files /dev/null and b/reference/superClass-1.png differ
diff --git a/reference/superClass.html b/reference/superClass.html
new file mode 100644
index 0000000..b2c388c
--- /dev/null
+++ b/reference/superClass.html
@@ -0,0 +1,370 @@
+
+Supervised Classification — superClass • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Supervised classification both for classification and regression mode based on vector training data (points or polygons).
+
+
+
+
Usage
+
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 ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Typically remote sensing imagery, which is to be classified.
+
+
+trainData
+sf or sp spatial vector data containing the training locations (POINTs,or POLYGONs).
+
+
+valData
+Ssf or sp spatial vector data containing the validation locations (POINTs,or POLYGONs) (optional).
+
+
+responseCol
+Character or integer giving the column in trainData
, which contains the response variable. Can be omitted, when trainData
has only one column.
+
+
+nSamples
+Integer. Number of samples per land cover class. If NULL
all pixels covered by training polygons are used (memory intensive!). Ignored if trainData consists of POINTs.
+
+
+nSamplesV
+Integer. Number of validation samples per land cover class. If NULL
all pixels covered by validation polygons are used (memory intensive!). Ignored if valData consists of POINTs.
+
+
+polygonBasedCV
+Logical. If TRUE
model tuning during cross-validation is conducted on a per-polygon basis. Use this to deal with overfitting issues. Does not affect training data supplied as SpatialPointsDataFrames.
+
+
+trainPartition
+Numeric. Partition (polygon based) of trainData
that goes into the training data set between zero and one. Ignored if valData
is provided.
+
+
+model
+Character. Which model to use. See train for options. Defaults to randomForest ('rf'). In addition to the standard caret models, a maximum likelihood classification is available via model = 'mlc'
.
+
+
+tuneLength
+Integer. Number of levels for each tuning parameter (see train for details).
+
+
+kfold
+Integer. Number of cross-validation resamples during model tuning.
+
+
+minDist
+Numeric. Minumum distance between training and validation data,
+ e.g. minDist=1
clips validation polygons to ensure a minimal distance of one pixel (pixel size according to img
) to the next training polygon.
+Requires all data to carry valid projection information.
+
+
+mode
+Character. Model type: 'regression' or 'classification'.
+
+
+predict
+Logical. Produce a map (TRUE, default) or only fit and validate the model (FALSE).
+
+
+predType
+Character. Type of the final output raster. Either "raw" for class predictions or "prob" for class probabilities. Class probabilities are not available for all classification models (predict.train ).
+
+
+filename
+Path to output file (optional). If NULL
, standard raster handling will apply, i.e. storage either in memory or in the raster temp directory.
+
+
+verbose
+Logical. prints progress and statistics during execution
+
+
+overwrite
+logical. Overwrite spatial prediction raster if it already exists.
+
+
+...
+further arguments to be passed to train
+
+
+
+
Value
+
+
+
A superClass object (effectively a list) containing:
$model: the fitted model
+$modelFit: model fit statistics
+$training: indexes of samples used for training
+$validation: list of
$performance: performance estimates based on independent validation (confusion matrix etc.)
+$validationSamples: actual pixel coordinates plus reference and predicted values used for validation
+$validationGeometry: validation polygpns (clipped with mindist to training geometries)
+
+$map: the predicted raster
+$classMapping: a data.frame containing an integer <-> label mapping
+
+
+
Details
+
SuperClass performs the following steps:
+
Ensure non-overlap between training and validation data. This is neccesary to avoid biased performance estimates.
+ A minimum distance (minDist
) in pixels can be provided to enforce a given distance between training and validation data.
+Sample training coordinates. If trainData
(and valData
if present) are polygons superClass
will calculate the area per polygon and sample
+nSamples
locations per class within these polygons. The number of samples per individual polygon scales with the polygon area, i.e. the bigger the polygon, the more samples.
+Split training/validation
+If valData
was provided (reccomended) the samples from these polygons will be held-out and not used for model fitting but only for validation.
+If trainPartition
is provided the trainingPolygons will be divided into training polygons and validation polygons.
+Extract raster data
+The predictor values on the sample pixels are extracted from img
+Fit the model. Using caret::train on the sampled training data the model
will be fit,
+including parameter tuning (tuneLength
) in kfold
cross-validation. polygonBasedCV=TRUE
will define cross-validation folds based on polygons (reccomended)
+otherwise it will be performed on a per-pixel basis.
+Predict the classes of all pixels in img
based on the final model.
+Validate the model with the independent validation data.
+
+
+
+
+
Examples
+
library ( caret )
+library ( randomForest )
+#> randomForest 4.7-1.1
+#> 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_lsat.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 )
+#> 08:20:47 | Begin sampling training data
+#> 08:20:48 | Starting to fit model
+#> 08:20:48 | Starting spatial predict
+#> 08:20:48 | 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
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/tasseledCap-1.png b/reference/tasseledCap-1.png
new file mode 100644
index 0000000..ce6553e
Binary files /dev/null and b/reference/tasseledCap-1.png differ
diff --git a/reference/tasseledCap.html b/reference/tasseledCap.html
new file mode 100644
index 0000000..7559beb
--- /dev/null
+++ b/reference/tasseledCap.html
@@ -0,0 +1,137 @@
+
+Tasseled Cap Transformation — tasseledCap • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Calculates brightness, greenness and wetness from multispectral imagery.
+Currently implemented Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5 and RapidEye.
+
+
+
+
Usage
+
tasseledCap ( img , sat , ... )
+
+
+
+
Arguments
+
img
+SpatRaster. Input image. Band order must correspond to sensor specifications (see Details and Examples)
+
+
+sat
+Character. Sensor; one of: c("Landsat4TM", "Landsat5TM", "Landsat7ETM", "Landsat8OLI", "MODIS", "QuickBird", "Spot5", "RapidEye"). Case is irrelevant.
+
+
+...
+Further arguments passed to writeRaster.
+
+
+
+
Value
+
+
+
Returns a SpatRaster with the thee bands: brigthness, greenness, and (soil) wetness.
+
+
+
Details
+
Currently implemented: Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5, RapdiEye.
+Input data must be in top of atmosphere reflectance.
+Moreover, bands must be provided in ascending order as listed in the table below.
+Irrelevant bands, such as Landsat Thermal Bands or QuickBird/Spot5 Panchromatic Bands must be omitted.
+Required bands are:
sat bands coefficients data unit Landsat4TM 1,2,3,4,5,7 Crist 1985 reflectance Landsat5TM 1,2,3,4,5,7 Crist 1985 reflectance Landsat7ETM 1,2,3,4,5,7 Huang 2002 reflectance Landsat8OLI 2,3,4,5,6,7 Baig 2014 reflectance MODIS 1,2,3,4,5,6,7 Lobser 2007 reflectance QuickBird 2,3,4,5 Yarbrough 2005 reflectance Spot5 2,3,4,5 Ivtis 2008 reflectance RapidEye 1,2,3,4,5 Schoenert 2014 reflectance
+
+
References
+
Crist (1985) "A TM Tasseled Cap Equivalent Transformation for Reflectance Factor Data." Remote Sensing of Environment 17 (3): 301-306
+
Huang et al. (2002) "Derivation of a Tasselled Cap Transformation Based on Landsat 7 At-Satellite Reflectance." International Journal of Remote Sensing 23 (8): 1741-1748
+
Baig et al. (2014) "Derivation of a Tasselled Cap Transformation Based on Landsat 8 At-Satellite Reflectance." Remote Sensing Letters 5 (5): 423-431.
+
Lobser et al. (2007) "MODIS Tasselled Cap: Land Cover Characteristics Expressed through Transformed MODIS Data." International Journal of Remote Sensing 28 (22): 5079-5101.
+
Yarbrough et al. (2005) "QuickBird 2 tasseled cap transform coefficients: a comparison of derivation methods." Pecora 16 Global Priorities in Land Remote Sensing: 23-27.
+
Ivits et al. (2008) "Orthogonal transformation of segmented SPOT5 images." Photogrammetric Engineering & Remote Sensing 74 (11): 1351-1364.
+
Schoenert et al. (2014) "Derivation of tasseled cap coefficients for RapidEye data." Earth Resources and Environmental Remote Sensing/GIS Applications V (9245): 92450Qs.
+
+
+
+
Examples
+
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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/topCor.html b/reference/topCor.html
new file mode 100644
index 0000000..6395893
--- /dev/null
+++ b/reference/topCor.html
@@ -0,0 +1,165 @@
+
+Topographic Illumination Correction — topCor • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
account and correct for changes in illumination due to terrain elevation.
+
+
+
+
Usage
+
topCor (
+ img ,
+ dem ,
+ metaData ,
+ solarAngles = c ( ) ,
+ method = "C" ,
+ stratImg = NULL ,
+ nStrat = 5 ,
+ illu ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster. Imagery to correct
+
+
+dem
+SpatRaster. Either a digital elevation model as a RasterLayer or a RasterStack/Brick with pre-calculated slope and aspect (see terrain ) in which case the layers must be named 'slope' and 'aspect'.
+Must have the same dimensions as img
.
+
+
+metaData
+Character, ImageMetaData. Either a path to a Landsat meta-data file (MTL) or an ImageMetaData object (see readMeta )
+
+
+solarAngles
+Numeric vector containing sun azimuth and sun zenith (in radians and in that order). Not needed if metaData is provided
+
+
+method
+Character. One of c("cos", "avgcos", "minnaert", "C", "stat", "illu"). Choosing 'illu' will return only the local illumination map.
+
+
+stratImg
+RasterLayer or SpatRaster to define strata, e.g. NDVI. Or the string 'slope' in which case stratification will be on nStrat
slope classes. Only relevant if method = 'minnaert'
.
+
+
+nStrat
+Integer. Number of bins or quantiles to stratify by. If a bin has less than 50 samples it will be merged with the next bin. Only relevant if method = 'minnaert'
.
+
+
+illu
+SpatRaster. Optional pre-calculated ilumination map. Run topCor with method="illu" to calculate an ilumination map
+
+
+...
+arguments passed to writeRaster
+
+
+
+
Value
+
+
+
SpatRaster
+
+
+
Details
+
For detailed discussion of the various approaches please see Riano et al. (2003).
+
The minnaert correction can be stratified for different landcover characteristics. If stratImg = 'slope'
the analysis is stratified by the slope,
+i.e. the slope values are divided into nStrat
classes and the correction coefficient k is calculated and applied separately for each slope class.
+An alternative could be to stratify by a vegetation index in which case an additional raster layer has to be provided via the stratImg
argument.
+
+
+
References
+
Riano et al. (2003) Assessment of different topographic correction in Landsat-TM data for mapping vegetation types. IEEE Transactions on Geoscience and Remote Sensing.
+
+
+
+
Examples
+
## 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" )
+#> 08:20:51 | Calculate slope and aspect
+#> 08:20:51 | Calculate illumination map
+#> 08:20:52 | Correct imagery
+#> 08:20:52 | Estimate coefficients
+
+## C correction, solar angles provided manually
+lsat_C <- topCor ( lsat , dem = srtm , solarAngles = c ( 1.081533 , 0.7023922 ) , method = "C" )
+#> 08:20:52 | Calculate slope and aspect
+#> 08:20:52 | Calculate illumination map
+#> 08:20:52 | Correct imagery
+#> 08:20:52 | Estimate coefficients
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/unsuperClass.html b/reference/unsuperClass.html
new file mode 100644
index 0000000..2564f3a
--- /dev/null
+++ b/reference/unsuperClass.html
@@ -0,0 +1,179 @@
+
+Unsupervised Classification — unsuperClass • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Unsupervised clustering of SpatRaster data using kmeans clustering
+
+
+
+
Usage
+
unsuperClass (
+ img ,
+ nSamples = 10000 ,
+ nClasses = 5 ,
+ nStarts = 25 ,
+ nIter = 100 ,
+ norm = FALSE ,
+ clusterMap = TRUE ,
+ algorithm = "Hartigan-Wong" ,
+ output = "classes" ,
+ ...
+)
+
+
+
+
Arguments
+
img
+SpatRaster.
+
+
+nSamples
+Integer. Number of random samples to draw to fit cluster map. Only relevant if clusterMap = TRUE.
+
+
+nClasses
+Integer. Number of classes.
+
+
+nStarts
+Integer. Number of random starts for kmeans algorithm.
+
+
+nIter
+Integer. Maximal number of iterations allowed.
+
+
+norm
+Logical. If TRUE
will normalize img first using normImage . Normalizing is beneficial if your predictors have different scales.
+
+
+clusterMap
+Logical. Fit kmeans model to a random subset of the img (see Details).
+
+
+algorithm
+Character. kmeans algorithm. One of c("Hartigan-Wong", "Lloyd", "MacQueen")
+
+
+output
+Character. Either 'classes' (kmeans class; default) or 'distances' (euclidean distance to each cluster center).
+
+
+...
+further arguments to be passed to writeRaster , e.g. filename
+
+
+
+
Value
+
+
+
Returns an RStoolbox::unsuperClass object, which is a list containing the kmeans model ($model) and the raster map ($map).
+For output = "classes", $map contains a SpatRaster with discrete classes (kmeans clusters); for output = "distances" $map contains
+a SpatRaster, with `nClasses` layers, where each layer maps the euclidean distance to the corresponding class centroid.
+
+
+
Details
+
Clustering is done using kmeans
. This can be done for all pixels of the image (clusterMap=FALSE
), however this can be slow and is
+not memory safe. Therefore if you have large raster data (> memory), as is typically the case with remote sensing imagery it is advisable to choose clusterMap=TRUE (the default).
+This means that a kmeans cluster model is calculated based on a random subset of pixels (nSamples
). Then the distance of *all* pixels to the cluster centers
+is calculated in a stepwise fashion using predict
. Class assignment is based on minimum euclidean distance to the cluster centers.
+
The solution of the kmeans algorithm often depends on the initial configuration of class centers which is chosen randomly.
+Therefore, kmeans is usually run with multiple random starting configurations in order to find a convergent solution from different starting configurations.
+The nStarts
argument allows to specify how many random starts are conducted.
+
+
+
+
Examples
+
if ( FALSE ) {
+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
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/validateMap.html b/reference/validateMap.html
new file mode 100644
index 0000000..d7b7454
--- /dev/null
+++ b/reference/validateMap.html
@@ -0,0 +1,184 @@
+
+Map accuracy assessment — validateMap • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
validate a map from a classification or regression model. This can be useful to update the accuracy assessment after filtering, e.g. for a minimum mapping unit.
+
+
+
+
Usage
+
validateMap (
+ map ,
+ valData ,
+ responseCol ,
+ nSamplesV = 500 ,
+ mode = "classification" ,
+ classMapping = NULL
+)
+
+
+
+
Arguments
+
map
+SpatRaster. The classified map.
+
+
+valData
+sf object with validation data (POLYGONs or POINTs).
+
+
+responseCol
+Character. Column containing the validation data in attribute table of valData
.
+
+
+nSamplesV
+Integer. Number of pixels to sample for validation (only applies to polygons).
+
+
+mode
+Character. Either 'classification' or 'regression'.
+
+
+classMapping
+optional data.frame with columns 'class'
and 'classID'
defining the mapping from raster integers to class names.
+
+
+
+
Value
+
+
+
Returns a structured list includng the preformance and confusion-matrix of your then validated input data
+
+
+
+
Examples
+
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" )
+#> 08:20:53 | Begin sampling training data
+#> 08:20:54 | Starting to fit model
+#> 08:20:54 | 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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reference/writeSLI-1.png b/reference/writeSLI-1.png
new file mode 100644
index 0000000..7e70d32
Binary files /dev/null and b/reference/writeSLI-1.png differ
diff --git a/reference/writeSLI.html b/reference/writeSLI.html
new file mode 100644
index 0000000..341fbf0
--- /dev/null
+++ b/reference/writeSLI.html
@@ -0,0 +1,149 @@
+
+Write ENVI spectral libraries — writeSLI • RStoolbox
+ Skip to contents
+
+
+
+
+
+
+
+
+
Writes binary ENVI spectral library files (sli) with accompanying header (.sli.hdr) files OR ASCII spectral library files in ENVI format.
+
+
+
+
Usage
+
writeSLI (
+ x ,
+ path ,
+ wavl.units = "Micrometers" ,
+ scaleF = 1 ,
+ mode = "bin" ,
+ endian = .Platform $ endian
+)
+
+
+
+
Arguments
+
x
+data.frame with first column containing wavelengths and all other columns containing spectra.
+
+
+path
+path to spectral library file to be created.
+
+
+wavl.units
+wavelength units. Defaults to Micrometers. Nanometers is another typical option.
+
+
+scaleF
+optional reflectance scaling factor. Defaults to 1.
+
+
+mode
+character string specifying output file type. Must be one of "bin"
for binary .sli files or "ASCII"
for ASCII ENVI plot files.
+
+
+endian
+character. Optional. By default the endian is determined based on the platform, but can be forced manually by setting it to either "little" or "big".
+
+
+
+
Value
+
+
+
Does not return anything, write the SLI file directly to your drive for where your specified your path parameter
+
+
+
Details
+
ENVI spectral libraries with ending .sli are binary arrays with spectra saved in rows.
+
+
+
+
+
Examples
+
+## 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 )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rescaleImage.html b/rescaleImage.html
deleted file mode 100644
index ccb4848..0000000
--- a/rescaleImage.html
+++ /dev/null
@@ -1,145 +0,0 @@
-R: Linear Image Rescaling
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rescaleImage {RStoolbox} R Documentation
-
-
Linear Image Rescaling
-
-
Description
-
-
performs linear shifts of value ranges either to match min/max of another image (y
)
-or to any other min and max value (ymin
and ymax
).
-
-
-
-
Usage
-
-
rescaleImage(x, y, xmin, xmax, ymin, ymax, forceMinMax = FALSE, ...)
-
-
-
-
Arguments
-
-
-x
-
-patRaster or numeric vector. Image to normalise.
-
-y
-
-SpatRaster or numeric vector. Reference image. Optional. Used to extract min and max values if ymin or ymax are missing.
-
-xmin
-
-Numeric. Min value of x. Either a single value or one value per layer in x. If xmin is not provided it will be extracted from x.
-
-xmax
-
-Numeric. Max value of x. Either a single value or one value per layer in x. If xmax is not provided it will be extracted from x.
-
-ymin
-
-Numeric. Min value of y. Either a single value or one value per layer in x. If ymin is not provided it will be extracted from y.
-
-ymax
-
-Numeric. Max value of y. Either a single value or one value per layer in x. If ymax is not provided it will be extracted from y.
-
-forceMinMax
-
-Logical. Forces update of min and max data slots in x or y.
-
-...
-
-additional arguments passed to terra::writeRaster()
-
-
-
-
-
Details
-
-
Providing xmin
and xmax
values manually can be useful if the raster contains a variable of a known, fixed value range,
-e.g. NDVI from -1 to 1 but the actual pixel values don't encompass this entire range.
-By providing xmin = -1
and xmax = 1
the values can be rescaled to any other range,
-e.g. 1 to 100 while comparability to other rescaled NDVI scenes is retained.
-
-
-
-
Value
-
-
Returns a SpatRaster of the same dimensions as the input raster x
but shifted and stretched to the new limits.
-
-
-
-
See Also
-
-
histMatch
-
-
-
-
Examples
-
-
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, ...
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/rlogo.html b/rlogo.html
deleted file mode 100644
index 55c8da1..0000000
--- a/rlogo.html
+++ /dev/null
@@ -1,47 +0,0 @@
-R: Rlogo as SpatRaster
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rlogo {RStoolbox} R Documentation
-
-
Rlogo as SpatRaster
-
-
Description
-
-
Tiny example of raster data used to run examples.
-
-
-
-
Usage
-
-
rlogo
-
-
-
-
Examples
-
-
ggRGB(rlogo,r = 1,g = 2,b = 3)
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/rsOpts.html b/rsOpts.html
deleted file mode 100644
index 0e2b742..0000000
--- a/rsOpts.html
+++ /dev/null
@@ -1,62 +0,0 @@
-R: Set global options for RStoolbox
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rsOpts {RStoolbox} R Documentation
-
-
Set global options for RStoolbox
-
-
Description
-
-
shortcut to options(RStoolbox.*)
-
-
-
-
Usage
-
-
rsOpts(verbose)
-
-
-
-
Arguments
-
-
-verbose
-
-Logical. If TRUE
many functions will print status messages about the current processing step. By default verbose mode is disabled.
-
-
-
-
-
Value
-
-
No return, just a setter for the verbosiness of the RStoolbox package
-
-
-
-
Examples
-
-
rsOpts(verbose=TRUE)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/sam.html b/sam.html
deleted file mode 100644
index 0e751d7..0000000
--- a/sam.html
+++ /dev/null
@@ -1,102 +0,0 @@
-R: Spectral Angle Mapper
-
-
-
-
-
-
-
-
-
-
-
-
-
-
sam {RStoolbox} R Documentation
-
-
Spectral Angle Mapper
-
-
Description
-
-
Calculates the angle in spectral space between pixels and a set of reference spectra (endmembers) for image classification based on spectral similarity.
-
-
-
-
Usage
-
-
sam(img, em, angles = FALSE, ...)
-
-
-
-
Arguments
-
-
-img
-
-RasterBrick or RasterStack or SpatRaster. Remote sensing imagery.
-
-em
-
-Matrix or data.frame with endmembers. Each row should contain the endmember spectrum of a class, i.e. columns correspond to bands in img
. It is reccomended to set the rownames to class names.
-
-angles
-
-Logical. If TRUE
a RasterBrick containing each one layer per endmember will be returned containing the spectral angles.
-
-...
-
-further arguments to be passed to writeRaster
-
-
-
-
-
Details
-
-
For each pixel the spectral angle mapper calculates the angle between the vector defined by the pixel values and each endmember vector. The result of this is
-one raster layer for each endmember containing the spectral angle. The smaller the spectral angle the more similar a pixel is to a given endmember class.
-In a second step one can the go ahead an enforce thresholds of maximum angles or simply classify each pixel to the most similar endmember.
-
-
-
-
Value
-
-
SpatRaster
-If angles = FALSE
a single Layer will be returned in which each pixel is assigned to the closest endmember class (integer pixel values correspond to row order of em
.
-
-
-
-
Examples
-
-
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"))
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/saveRSTBX.html b/saveRSTBX.html
deleted file mode 100644
index 357378e..0000000
--- a/saveRSTBX.html
+++ /dev/null
@@ -1,118 +0,0 @@
-R: Save and Read RStoolbox Classification Results
-
-
-
-
-
-
-
-
-
-
-
-
-
-
saveRSTBX {RStoolbox} R Documentation
-
-
Save and Read RStoolbox Classification Results
-
-
Description
-
-
Saves objects of classes unsuperClass, superClass, rasterPCA and fCover to
-file. Useful to archive the fitted models.
-
-
-
-
Usage
-
-
saveRSTBX(x, filename, format = "raster", ...)
-
-readRSTBX(filename)
-
-
-
-
Arguments
-
-
-x
-
-RStoolbox object of classes c("fCover", "rasterPCA", "superClass", "unsuperClass")
-
-filename
-
-Character. Path and filename. Any file extension will be ignored.
-
-format
-
-Character. Driver to use for the raster file
-
-...
-
-further arguments passed to writeRaster
-
-
-
-
-
Value
-
-
The output of writeRSTBX will be at least two files written to disk:
-a) an .rds file containing the object itself and
-b) the raster file (depending on the driver you choose this can be more than two files).
-
-
-
-
Functions
-
-
-
-
-
-
Note
-
-
All files must be kept in the same directory to read the full object back into R
-by means of readRSTBX. You can move them to another location but you'll have to move *all* of them
-(just like you would with Shapefiles). In case the raster file(s) is missing, readRSTBX will still
-return the object but the raster will be missing.
-
-
writeRSTBX and readRSTBX are convenience wrappers around saveRDS, readRDS. This means
-you can read all files created this way also with base functionality as long as you don't move your files.
-This is because x$map is a SpatRaster object and hence contains only a static link to the file on disk.
-
-
-
-
Examples
-
-
## Not run:
-##D input <- rlogo
-##D ## Create filename
-##D file <- paste0(tempdir(), "/test", runif(1))
-##D ## Run PCA
-##D rpc <- rasterPCA(input, nSample = 100)
-##D ## Save object
-##D saveRSTBX(rpc, filename=file)
-##D ## Which files were written?
-##D list.files(tempdir(), pattern = basename(file))
-##D ## Re-read files
-##D re_rpc <- readRSTBX(file)
-##D ## Remove files
-##D file.remove(list.files(tempdir(), pattern = basename(file), full = TRUE))
-## End(Not run)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/search.json b/search.json
new file mode 100644
index 0000000..295cf6e
--- /dev/null
+++ b/search.json
@@ -0,0 +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.0, 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.0, https://github.com/bleutner/RStoolbox}, url = {https://bleutner.github.io/RStoolbox/}, }"},{"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/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: 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 rescaleImage: rescale image match min/max another image specified min/max range normImage: normalize imagery centering scaling histMatch: matches histograms two scenes coregisterImages: co-register images based mutual information panSharpen: sharpen coarse resolution image high resolution image (typically panchromatic)","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 unsuperClass: unsupervised classification superClass: supervised classification fCover: fractional cover coarse resolution imagery based high resolution classification","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.71 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) ## 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) ## 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_lsat.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 = 5, 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 5. 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': 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 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 (details, see http://bleutner.github.io/RStoolbox/r/2016/01/26/estimating-landsat-8-esun-values). 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)"},{"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.","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 RStoolbox package","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) { 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.","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\") #> 08:20:41 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn #> 08:20:41 | Thermal bands to convert to brightness temperature: B6_dn #> 08:20:41 | Processing thermal band(s) #> 08:20:41 | Processing radiance / reflectance SI <- spectralIndices(lsat_ref, red = \"B3_tre\", nir = \"B4_tre\") plot(SI) # }"},{"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":"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(caret) library(randomForest) #> randomForest 4.7-1.1 #> 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_lsat.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) #> 08:20:47 | Begin sampling training data #> 08:20:48 | Starting to fit model #> 08:20:48 | Starting spatial predict #> 08:20:48 | 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\") #> 08:20:51 | Calculate slope and aspect #> 08:20:51 | Calculate illumination map #> 08:20:52 | Correct imagery #> 08:20:52 | Estimate coefficients ## C correction, solar angles provided manually lsat_C <- topCor(lsat, dem = srtm, solarAngles = c(1.081533, 0.7023922), method = \"C\") #> 08:20:52 | Calculate slope and aspect #> 08:20:52 | Calculate illumination map #> 08:20:52 | Correct imagery #> 08:20:52 | 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) { 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\") #> 08:20:53 | Begin sampling training data #> 08:20:54 | Starting to fit model #> 08:20:54 | 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":[]},{"path":"https://bleutner.github.io/RStoolbox/news/index.html","id":"new-0-4-1","dir":"Changelog","previous_headings":"","what":"New:","title":"RStoolbox 0.4.1","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-0-4-1","dir":"Changelog","previous_headings":"","what":"Changes:","title":"RStoolbox 0.4.1","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-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 (validationgeometry) also exact samples taken validation including cell number coordinates (validationvalidationSamples) 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":""}]
diff --git a/sitemap.xml b/sitemap.xml
new file mode 100644
index 0000000..9fedfcc
--- /dev/null
+++ b/sitemap.xml
@@ -0,0 +1,159 @@
+
+
+
+ https://bleutner.github.io/RStoolbox/404.html
+
+
+ https://bleutner.github.io/RStoolbox/authors.html
+
+
+ https://bleutner.github.io/RStoolbox/index.html
+
+
+ https://bleutner.github.io/RStoolbox/news/index.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/ImageMetaData.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/RStoolbox.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/classifyQA.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/cloudMask.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/cloudShadowMask.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/coregisterImages.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/decodeQA.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/encodeQA.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/estimateHaze.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/fCover.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/fortifySpatRaster.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/getMeta.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/getValidation.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/ggR.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/ggRGB.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/histMatch.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/index.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/lsat.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/mesma.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/normImage.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/oneHotEncode.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/panSharpen.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/pifMatch.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/pipe.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/predict.unsuperClass.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/radCor.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rasterCVA.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rasterEntropy.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rasterPCA.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/readEE.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/readMeta.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/readSLI.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rescaleImage.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rlogo.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/rsOpts.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/sam.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/saveRSTBX.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/sen2.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/spectralIndices.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/srtm.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/srtm_sen2.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/stackMeta.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/superClass.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/tasseledCap.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/topCor.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/unsuperClass.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/validateMap.html
+
+
+ https://bleutner.github.io/RStoolbox/reference/writeSLI.html
+
+
diff --git a/spectralIndices.html b/spectralIndices.html
deleted file mode 100644
index 6fbc681..0000000
--- a/spectralIndices.html
+++ /dev/null
@@ -1,391 +0,0 @@
-R: Spectral Indices
-
-
-
-
-
-
-
-
-
-
-
-
-
-
spectralIndices {RStoolbox} R Documentation
-
-
Spectral Indices
-
-
Description
-
-
Calculate a suite of multispectral indices such as NDVI, SAVI etc. in an efficient way.
-
-
-
-
Usage
-
-
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),
- ...
-)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster, Typically remote sensing imagery, which is to be classified.
-
-blue
-
-Character or integer. Blue band.
-
-green
-
-Character or integer. Green band.
-
-red
-
-Character or integer. Red band.
-
-nir
-
-Character or integer. Near-infrared band (700-1100nm).
-
-redEdge1
-
-Character or integer. Red-edge band (705nm)
-
-redEdge2
-
-Character or integer. Red-edge band (740nm)
-
-redEdge3
-
-Character or integer. Red-edge band (783nm)
-
-swir1
-
-not used
-
-swir2
-
-Character or integer. Short-wave-infrared band (1400-1800nm).
-
-swir3
-
-Character or integer. Short-wave-infrared band (2000-2500nm).
-
-scaleFactor
-
-Numeric. Scale factor for the conversion of scaled reflectances to [0,1] value range (applied as reflectance/scaleFactor) Neccesary for calculating EVI/EVI2 with scaled reflectance values.
-
-skipRefCheck
-
-Logical. When EVI/EVI2 is to be calculated there is a rough heuristic check, whether the data are inside [0,1]+/-0.5 (after applying a potential scaleFactor
).
-If there are invalid reflectances, e.g. clouds with reflectance > 1 this check will result in a false positive and skip EVI calculation. Use this argument to skip this check in such cases *iff* you are sure the data and scaleFactor are valid.
-
-indices
-
-Character. One or more spectral indices to calculate (see Details). By default (NULL) all implemented indices given the spectral bands which are provided will be calculated.
-
-index
-
-Character. Alias for indices
.
-
-maskLayer
-
-RasterLayer or SpatRaster containing a mask, e.g. clouds, for which pixels are set to NA. Alternatively a layername or -number can be provided if the mask is part of img
.
-
-maskValue
-
-Integer. Pixel value in maskLayer
which should be masked in output, i.e. will be set to NA
in all calculated indices.
-
-coefs
-
-List of coefficients (see Details).
-
-...
-
-further arguments such as filename etc. passed to writeRaster
-
-
-
-
-
Details
-
-
spectralIndices
calculates all indices in one go in C++, which is more efficient than calculating each index separately (for large rasters).
-By default all indices which can be calculated given the specified indices will be calculated. If you don't want all indices, use the indices
argument to specify exactly which indices are to be calculated.
-See the table bellow for index names and required bands.
-
-
Index values outside the valid value ranges (if such a range exists) will be set to NA. For example a pixel with NDVI > 1 will be set to NA.
-
-
-
-
- Index Description Source Bands Formula
-
-
- CLG Green-band Chlorophyll Index Gitelson2003 redEdge3, green
redEdge3/green - 1
-
-
- CLRE Red-edge-band Chlorophyll Index Gitelson2003 redEdge3, redEdge1
redEdge3/redEdge1 - 1
-
-
- CTVI Corrected Transformed Vegetation Index Perry1984 red, nir
(NDVI + 0.5)/sqrt(abs(NDVI + 0.5))
-
-
- DVI Difference Vegetation Index Richardson1977 red, nir
s * nir - red
-
-
- EVI Enhanced Vegetation Index Huete1999 red, nir, blue
G * ((nir - red)/(nir + C1 * red - C2 * blue + L_evi))
-
-
- EVI2 Two-band Enhanced Vegetation Index Jiang 2008 red, nir
G * (nir - red)/(nir + 2.4 * red + 1)
-
-
- GEMI Global Environmental Monitoring Index Pinty1992 red, nir
(((nir^2 - red^2) * 2 + (nir * 1.5) + (red * 0.5))/(nir + red + 0.5)) * (1 - ((((nir^2 - red^2) * 2 + (nir * 1.5) + (red * 0.5))/(nir + red + 0.5)) * 0.25)) - ((red - 0.125)/(1 - red))
-
-
- GNDVI Green Normalised Difference Vegetation Index Gitelson1998 green, nir
(nir - green)/(nir + green)
-
-
- KNDVI Kernel Normalised Difference Vegetation Index Camps-Valls2021 red, nir
tanh(((nir - red)/(nir + red)))^2
-
-
- MCARI Modified Chlorophyll Absorption Ratio Index Daughtery2000 green, red, redEdge1
((redEdge1 - red) - (redEdge1 - green)) * (redEdge1/red)
-
-
- MNDWI Modified Normalised Difference Water Index Xu2006 green, swir2
(green - swir2)/(green + swir2)
-
-
- MSAVI Modified Soil Adjusted Vegetation Index Qi1994 red, nir
nir + 0.5 - (0.5 * sqrt((2 * nir + 1)^2 - 8 * (nir - (2 * red))))
-
-
- MSAVI2 Modified Soil Adjusted Vegetation Index 2 Qi1994 red, nir
(2 * (nir + 1) - sqrt((2 * nir + 1)^2 - 8 * (nir - red)))/2
-
-
- MTCI MERIS Terrestrial Chlorophyll Index DashAndCurran2004 red, redEdge1, redEdge2
(redEdge2 - redEdge1)/(redEdge1 - red)
-
-
- NBRI Normalised Burn Ratio Index Garcia1991 nir, swir3
(nir - swir3)/(nir + swir3)
-
-
- NDREI1 Normalised Difference Red Edge Index 1 GitelsonAndMerzlyak1994 redEdge2, redEdge1
(redEdge2 - redEdge1)/(redEdge2 + redEdge1)
-
-
- NDREI2 Normalised Difference Red Edge Index 2 Barnes2000 redEdge3, redEdge1
(redEdge3 - redEdge1)/(redEdge3 + redEdge1)
-
-
- NDVI Normalised Difference Vegetation Index Rouse1974 red, nir
(nir - red)/(nir + red)
-
-
- NDVIC Corrected Normalised Difference Vegetation Index Nemani1993 red, nir, swir2
(nir - red)/(nir + red) * (1 - ((swir2 - swir2ccc)/(swir2coc - swir2ccc)))
-
-
- NDWI Normalised Difference Water Index McFeeters1996 green, nir
(green - nir)/(green + nir)
-
-
- NDWI2 Normalised Difference Water Index Gao1996 nir, swir2
(nir - swir2)/(nir + swir2)
-
-
- NRVI Normalised Ratio Vegetation Index Baret1991 red, nir
(red/nir - 1)/(red/nir + 1)
-
-
- REIP Red Edge Inflection Point GuyotAndBarnet1988 red, redEdge1, redEdge2, redEdge3
0.705 + 0.35 * ((red + redEdge3)/(2 - redEdge1))/(redEdge2 - redEdge1)
-
-
- RVI Ratio Vegetation Index red, nir
red/nir
-
-
- SATVI Soil Adjusted Total Vegetation Index Marsett2006 red, swir2, swir3
(swir2 - red)/(swir2 + red + L) * (1 + L) - (swir3/2)
-
-
- SAVI Soil Adjusted Vegetation Index Huete1988 red, nir
(nir - red) * (1 + L)/(nir + red + L)
-
-
- SLAVI Specific Leaf Area Vegetation Index Lymburger2000 red, nir, swir2
nir/(red + swir2)
-
-
- SR Simple Ratio Vegetation Index Birth1968 red, nir
nir/red
-
-
- TTVI Thiam's Transformed Vegetation Index Thiam1997 red, nir
sqrt(abs((nir - red)/(nir + red) + 0.5))
-
-
- TVI Transformed Vegetation Index Deering1975 red, nir
sqrt((nir - red)/(nir + red) + 0.5)
-
-
- WDVI Weighted Difference Vegetation Index Richardson1977 red, nir
nir - s * red
-
-
-
-
-
Some indices require additional parameters, such as the slope of the soil line which are specified via a list to the coefs
argument.
-Although the defaults are sensible values, values like the soil brightnes factor L
for SAVI should be adapted depending on the characteristics of the scene.
-The coefficients are:
-
-
-
-
-
-Coefficient Description Affected Indices
-
-
-
-s
slope of the soil line DVI, WDVI
-
-
-
-L_evi, C1, C2, G
various EVI
-
-
-
-L
soil brightness factor SAVI, SATVI
-
-
-
-swir2ccc
minimum swir2 value (completely closed forest canopy) NDVIC
-
-
-
-swir2coc
maximum swir2 value (completely open canopy) NDVIC
-
-
-
-
-
-
-
-
-
The wavelength band names are defined following Schowengertd 2007, p10.
-The last column shows exemplarily which Landsat 5 TM bands correspond to which wavelength range definition.
-
-
-
-
- Band Description Wavl_min Wavl_max Landsat5_Band Sentinel2_Band
-
-
- vis visible 400 680 1,2,3 2,3,4
-
-
- red-edge1 red-edge1 680 720 - 5
-
-
- red-edge2 red-edge2 720 760 - 6
-
-
- red-edge3 red-edge3 760 800 - 7
-
-
- nir near infra-red 800 1100 4 8/8a
-
-
- swir1 short-wave infra-red 1100 1351 - 9,10
-
-
- swir2 short-wave infra-red 1400 1800 5 11
-
-
- swir3 short-wave infra-red 2000 2500 7 12
-
-
- mir1 mid-wave infra-red 3000 4000 - -
-
-
- mir2 mid-wave infra-red 45000 5000 - -
-
-
- tir1 thermal infra-red 8000 9500 - -
-
-
- tir2 thermal infra-red 10000 140000 6 -
-
-
-
-
-
-
-
Value
-
-
SpatRaster
-
-
-
-
Examples
-
-
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"))
-
-
-
## No test:
-
-## 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")
-
-
## 01:39:38 | Bands to convert to reflectance: B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B7_dn
-
-
## 01:39:38 | Thermal bands to convert to brightness temperature: B6_dn
-
-
## 01:39:38 | Processing thermal band(s)
-
-
## 01:39:38 | Processing radiance / reflectance
-
-
SI <- spectralIndices(lsat_ref, red = "B3_tre", nir = "B4_tre")
-plot(SI)
-
-
-
## End(No test)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/srtm.html b/srtm.html
deleted file mode 100644
index 2b76565..0000000
--- a/srtm.html
+++ /dev/null
@@ -1,47 +0,0 @@
-R: SRTM Digital Elevation Model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
srtm {RStoolbox} R Documentation
-
-
SRTM Digital Elevation Model
-
-
Description
-
-
DEM for the Landsat example area taken from SRTM v3 tile: s04_w050_1arc_v3.tif
-
-
-
-
Usage
-
-
srtm
-
-
-
-
Examples
-
-
ggR(srtm)
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/stackMeta.html b/stackMeta.html
deleted file mode 100644
index 84e2ffe..0000000
--- a/stackMeta.html
+++ /dev/null
@@ -1,164 +0,0 @@
-R: Import separate Landsat files into single stack
-
-
-
-
-
-
-
-
-
-
-
-
-
-
stackMeta {RStoolbox} R Documentation
-
-
Import separate Landsat files into single stack
-
-
Description
-
-
Reads Landsat MTL or XML metadata files and loads single Landsat Tiffs into a rasterStack.
-Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m.
-
-
-
-
Usage
-
-
stackMeta(file, quantity = "all", category = "image", allResolutions = FALSE)
-
-
-
-
Arguments
-
-
-file
-
-Character. Path to Landsat MTL metadata (*_MTL.txt) file or an Landsat CDR xml metadata file (*.xml).
-
-quantity
-
-Character vector. Which quantity should be returned. Options: digital numbers ('dn'), top of atmosphere reflectance ('tre'), at surface reflectance ('sre'), brightness temperature ('bt'), spectral index ('index'), all quantities ('all').
-
-category
-
-Character vector. Which category of data to return. Options 'image': image data, 'pan': panchromatic image, 'index': multiband indices, 'qa' quality flag bands, 'all': all categories.
-
-allResolutions
-
-Logical. if TRUE
a list will be returned with length = unique spatial resolutions.
-This argument was introduced to maintain backward compatibility and will be switched to TRUE in an upcoming release. Please base all new code on terra.
-
-
-
-
-
Value
-
-
Returns one single SpatRaster comprising all requested bands.
-If allResolutions = TRUE
*and* there are different resolution layers (e.g. a 15m panchromatic band along wit 30m imagery) a list of RasterStacks will be returned.
-
-
-
-
Note
-
-
Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m. Use the allResolutions argument to import all layers.
-Note that nowadays the USGS uses cubic convolution to resample the TIR bands to 30m resolution.
-
-
-
-
Examples
-
-
## 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):
-## dn -> radiance (toa)
-## dn -> 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, ...
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/superClass.html b/superClass.html
deleted file mode 100644
index cb8a90c..0000000
--- a/superClass.html
+++ /dev/null
@@ -1,406 +0,0 @@
-R: Supervised Classification
-
-
-
-
-
-
-
-
-
-
-
-
-
-
superClass {RStoolbox} R Documentation
-
-
Supervised Classification
-
-
Description
-
-
Supervised classification both for classification and regression mode based on vector training data (points or polygons).
-
-
-
-
Usage
-
-
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,
- ...
-)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster. Typically remote sensing imagery, which is to be classified.
-
-trainData
-
-sf or sp spatial vector data containing the training locations (POINTs,or POLYGONs).
-
-valData
-
-Ssf or sp spatial vector data containing the validation locations (POINTs,or POLYGONs) (optional).
-
-responseCol
-
-Character or integer giving the column in trainData
, which contains the response variable. Can be omitted, when trainData
has only one column.
-
-nSamples
-
-Integer. Number of samples per land cover class. If NULL
all pixels covered by training polygons are used (memory intensive!). Ignored if trainData consists of POINTs.
-
-nSamplesV
-
-Integer. Number of validation samples per land cover class. If NULL
all pixels covered by validation polygons are used (memory intensive!). Ignored if valData consists of POINTs.
-
-polygonBasedCV
-
-Logical. If TRUE
model tuning during cross-validation is conducted on a per-polygon basis. Use this to deal with overfitting issues. Does not affect training data supplied as SpatialPointsDataFrames.
-
-trainPartition
-
-Numeric. Partition (polygon based) of trainData
that goes into the training data set between zero and one. Ignored if valData
is provided.
-
-model
-
-Character. Which model to use. See train for options. Defaults to randomForest ('rf'). In addition to the standard caret models, a maximum likelihood classification is available via model = 'mlc'
.
-
-tuneLength
-
-Integer. Number of levels for each tuning parameter (see train for details).
-
-kfold
-
-Integer. Number of cross-validation resamples during model tuning.
-
-minDist
-
-Numeric. Minumum distance between training and validation data,
-e.g. minDist=1
clips validation polygons to ensure a minimal distance of one pixel (pixel size according to img
) to the next training polygon.
-Requires all data to carry valid projection information.
-
-mode
-
-Character. Model type: 'regression' or 'classification'.
-
-predict
-
-Logical. Produce a map (TRUE, default) or only fit and validate the model (FALSE).
-
-predType
-
-Character. Type of the final output raster. Either "raw" for class predictions or "prob" for class probabilities. Class probabilities are not available for all classification models (predict.train ).
-
-filename
-
-Path to output file (optional). If NULL
, standard raster handling will apply, i.e. storage either in memory or in the raster temp directory.
-
-verbose
-
-Logical. prints progress and statistics during execution
-
-overwrite
-
-logical. Overwrite spatial prediction raster if it already exists.
-
-...
-
-further arguments to be passed to train
-
-
-
-
-
Details
-
-
SuperClass performs the following steps:
-
-
-
- Ensure non-overlap between training and validation data. This is neccesary to avoid biased performance estimates.
-A minimum distance (minDist
) in pixels can be provided to enforce a given distance between training and validation data.
-
-
- Sample training coordinates. If trainData
(and valData
if present) are polygons superClass
will calculate the area per polygon and sample
-nSamples
locations per class within these polygons. The number of samples per individual polygon scales with the polygon area, i.e. the bigger the polygon, the more samples.
-
-
- Split training/validation
-If valData
was provided (reccomended) the samples from these polygons will be held-out and not used for model fitting but only for validation.
-If trainPartition
is provided the trainingPolygons will be divided into training polygons and validation polygons.
-
-
- Extract raster data
-The predictor values on the sample pixels are extracted from img
-
-
- Fit the model. Using caret::train on the sampled training data the model
will be fit,
-including parameter tuning (tuneLength
) in kfold
cross-validation. polygonBasedCV=TRUE
will define cross-validation folds based on polygons (reccomended)
-otherwise it will be performed on a per-pixel basis.
-
-
- Predict the classes of all pixels in img
based on the final model.
-
-
- Validate the model with the independent validation data.
-
-
-
-
-
-
Value
-
-
A superClass object (effectively a list) containing:
-
-
-
- $model: the fitted model
-
-
- $modelFit: model fit statistics
-
-
- $training: indexes of samples used for training
-
-
- $validation: list of
-
-
-
- $performance: performance estimates based on independent validation (confusion matrix etc.)
-
-
- $validationSamples: actual pixel coordinates plus reference and predicted values used for validation
-
-
- $validationGeometry: validation polygpns (clipped with mindist to training geometries)
-
-
-
-
- $map: the predicted raster
-
-
- $classMapping: a data.frame containing an integer <-> label mapping
-
-
-
-
-
-
See Also
-
-
train
-
-
-
-
Examples
-
-
library(caret)
-library(randomForest)
-
-
## Warning: package 'randomForest' was built under R version 4.2.3
-
-
## randomForest 4.7-1.1
-
-
## 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)
-
-
## Warning: package 'e1071' was built under R version 4.2.3
-
-
##
-## Attaching package: 'e1071'
-
-
## The following object is masked from 'package:terra':
-##
-## interpolate
-
-
library(terra)
-train <- readRDS(system.file("external/trainingPoints.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)
-
-
## 01:39:41 | Begin sampling training data
-
-
## 01:39:41 | Starting to fit model
-
-
## 01:39:42 | Starting spatial predict
-
-
## 01:39:42 | 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, 18, 17, 16, 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
-## 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
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/tasseledCap.html b/tasseledCap.html
deleted file mode 100644
index eb45ea1..0000000
--- a/tasseledCap.html
+++ /dev/null
@@ -1,161 +0,0 @@
-R: Tasseled Cap Transformation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
tasseledCap {RStoolbox} R Documentation
-
-
Tasseled Cap Transformation
-
-
Description
-
-
Calculates brightness, greenness and wetness from multispectral imagery.
-Currently implemented Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5 and RapidEye.
-
-
-
-
Usage
-
-
tasseledCap(img, sat, ...)
-
-
-
-
Arguments
-
-
-img
-
-RasterBrick or RasterStack or SpatRaster. Input image. Band order must correspond to sensor specifications (see Details and Examples)
-
-sat
-
-Character. Sensor; one of: c("Landsat4TM", "Landsat5TM", "Landsat7ETM", "Landsat8OLI", "MODIS", "QuickBird", "Spot5", "RapidEye"). Case is irrelevant.
-
-...
-
-Further arguments passed to writeRaster.
-
-
-
-
-
Details
-
-
Currently implemented: Landsat 4 TM, Landsat 5 TM, Landsat 7ETM+, Landsat 8 OLI, MODIS, QuickBird, Spot5, RapdiEye.
-Input data must be in top of atmosphere reflectance.
-Moreover, bands must be provided in ascending order as listed in the table below.
-Irrelevant bands, such as Landsat Thermal Bands or QuickBird/Spot5 Panchromatic Bands must be omitted.
-Required bands are:
-
-
-
-
-
- sat bands coefficients data unit
-
-
-
- Landsat4TM 1,2,3,4,5,7 Crist 1985 reflectance
-
-
-
- Landsat5TM 1,2,3,4,5,7 Crist 1985 reflectance
-
-
-
- Landsat7ETM 1,2,3,4,5,7 Huang 2002 reflectance
-
-
-
- Landsat8OLI 2,3,4,5,6,7 Baig 2014 reflectance
-
-
-
- MODIS 1,2,3,4,5,6,7 Lobser 2007 reflectance
-
-
-
- QuickBird 2,3,4,5 Yarbrough 2005 reflectance
-
-
-
- Spot5 2,3,4,5 Ivtis 2008 reflectance
-
-
-
- RapidEye 1,2,3,4,5 Schoenert 2014 reflectance
-
-
-
-
-
-
-
-
-
-
-
Value
-
-
Returns a SpatRaster with the thee bands: brigthness, greenness, and (soil) wetness.
-
-
-
-
References
-
-
Crist (1985) "A TM Tasseled Cap Equivalent Transformation for Reflectance Factor Data." Remote Sensing of Environment 17 (3): 301-306
-
-
Huang et al. (2002) "Derivation of a Tasselled Cap Transformation Based on Landsat 7 At-Satellite Reflectance." International Journal of Remote Sensing 23 (8): 1741-1748
-
-
Baig et al. (2014) "Derivation of a Tasselled Cap Transformation Based on Landsat 8 At-Satellite Reflectance." Remote Sensing Letters 5 (5): 423-431.
-
-
Lobser et al. (2007) "MODIS Tasselled Cap: Land Cover Characteristics Expressed through Transformed MODIS Data." International Journal of Remote Sensing 28 (22): 5079-5101.
-
-
Yarbrough et al. (2005) "QuickBird 2 tasseled cap transform coefficients: a comparison of derivation methods." Pecora 16 Global Priorities in Land Remote Sensing: 23-27.
-
-
Ivits et al. (2008) "Orthogonal transformation of segmented SPOT5 images." Photogrammetric Engineering & Remote Sensing 74 (11): 1351-1364.
-
-
Schoenert et al. (2014) "Derivation of tasseled cap coefficients for RapidEye data." Earth Resources and Environmental Remote Sensing/GIS Applications V (9245): 92450Qs.
-
-
-
-
Examples
-
-
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. : WGS 84 / UTM zone 22N (EPSG:32622)
-## 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)
-
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/topCor.html b/topCor.html
deleted file mode 100644
index 9687b60..0000000
--- a/topCor.html
+++ /dev/null
@@ -1,147 +0,0 @@
-R: Topographic Illumination Correction
-
-
-
-
-
-
-
-
-
-
-
-
-
-
topCor {RStoolbox} R Documentation
-
-
Topographic Illumination Correction
-
-
Description
-
-
account and correct for changes in illumination due to terrain elevation.
-
-
-
-
Usage
-
-
topCor(
- img,
- dem,
- metaData,
- solarAngles = c(),
- method = "C",
- stratImg = NULL,
- nStrat = 5,
- illu,
- ...
-)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster. Imagery to correct
-
-dem
-
-SpatRaster. Either a digital elevation model as a RasterLayer or a RasterStack/Brick with pre-calculated slope and aspect (see terrain ) in which case the layers must be named 'slope' and 'aspect'.
-Must have the same dimensions as img
.
-
-metaData
-
-Character, ImageMetaData. Either a path to a Landsat meta-data file (MTL) or an ImageMetaData object (see readMeta )
-
-solarAngles
-
-Numeric vector containing sun azimuth and sun zenith (in radians and in that order). Not needed if metaData is provided
-
-method
-
-Character. One of c("cos", "avgcos", "minnaert", "C", "stat", "illu"). Choosing 'illu' will return only the local illumination map.
-
-stratImg
-
-RasterLayer or SpatRaster to define strata, e.g. NDVI. Or the string 'slope' in which case stratification will be on nStrat
slope classes. Only relevant if method = 'minnaert'
.
-
-nStrat
-
-Integer. Number of bins or quantiles to stratify by. If a bin has less than 50 samples it will be merged with the next bin. Only relevant if method = 'minnaert'
.
-
-illu
-
-SpatRaster. Optional pre-calculated ilumination map. Run topCor with method="illu" to calculate an ilumination map
-
-...
-
-arguments passed to writeRaster
-
-
-
-
-
Details
-
-
For detailed discussion of the various approaches please see Riano et al. (2003).
-
-
The minnaert correction can be stratified for different landcover characteristics. If stratImg = 'slope'
the analysis is stratified by the slope,
-i.e. the slope values are divided into nStrat
classes and the correction coefficient k is calculated and applied separately for each slope class.
-An alternative could be to stratify by a vegetation index in which case an additional raster layer has to be provided via the stratImg
argument.
-
-
-
-
Value
-
-
SpatRaster
-
-
-
-
References
-
-
Riano et al. (2003) Assessment of different topographic correction in Landsat-TM data for mapping vegetation types. IEEE Transactions on Geoscience and Remote Sensing.
-
-
-
-
Examples
-
-
## 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")
-
-
## 01:39:44 | Calculate slope and aspect
-
-
## 01:39:44 | Calculate illumination map
-
-
## 01:39:44 | Correct imagery
-
-
## 01:39:44 | Estimate coefficients
-
-
## C correction, solar angles provided manually
-lsat_C <- topCor(lsat, dem = srtm, solarAngles = c(1.081533, 0.7023922), method = "C")
-
-
## 01:39:44 | Calculate slope and aspect
-
-
## 01:39:44 | Calculate illumination map
-
-
## 01:39:44 | Correct imagery
-
-
## 01:39:44 | Estimate coefficients
-
-
## Warning: [*] CRS do not match
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/unsuperClass.html b/unsuperClass.html
deleted file mode 100644
index c43f160..0000000
--- a/unsuperClass.html
+++ /dev/null
@@ -1,150 +0,0 @@
-R: Unsupervised Classification
-
-
-
-
-
-
-
-
-
-
-
-
-
-
unsuperClass {RStoolbox} R Documentation
-
-
Unsupervised Classification
-
-
Description
-
-
Unsupervised clustering of SpatRaster data using kmeans clustering
-
-
-
-
Usage
-
-
unsuperClass(
- img,
- nSamples = 10000,
- nClasses = 5,
- nStarts = 25,
- nIter = 100,
- norm = FALSE,
- clusterMap = TRUE,
- algorithm = "Hartigan-Wong",
- output = "classes",
- ...
-)
-
-
-
-
Arguments
-
-
-img
-
-SpatRaster.
-
-nSamples
-
-Integer. Number of random samples to draw to fit cluster map. Only relevant if clusterMap = TRUE.
-
-nClasses
-
-Integer. Number of classes.
-
-nStarts
-
-Integer. Number of random starts for kmeans algorithm.
-
-nIter
-
-Integer. Maximal number of iterations allowed.
-
-norm
-
-Logical. If TRUE
will normalize img first using normImage . Normalizing is beneficial if your predictors have different scales.
-
-clusterMap
-
-Logical. Fit kmeans model to a random subset of the img (see Details).
-
-algorithm
-
-Character. kmeans algorithm. One of c("Hartigan-Wong", "Lloyd", "MacQueen")
-
-output
-
-Character. Either 'classes' (kmeans class; default) or 'distances' (euclidean distance to each cluster center).
-
-...
-
-further arguments to be passed to writeRaster , e.g. filename
-
-
-
-
-
Details
-
-
Clustering is done using kmeans
. This can be done for all pixels of the image (clusterMap=FALSE
), however this can be slow and is
-not memory safe. Therefore if you have large raster data (> memory), as is typically the case with remote sensing imagery it is advisable to choose clusterMap=TRUE (the default).
-This means that a kmeans cluster model is calculated based on a random subset of pixels (nSamples
). Then the distance of *all* pixels to the cluster centers
-is calculated in a stepwise fashion using predict
. Class assignment is based on minimum euclidean distance to the cluster centers.
-
-
The solution of the kmeans algorithm often depends on the initial configuration of class centers which is chosen randomly.
-Therefore, kmeans is usually run with multiple random starting configurations in order to find a convergent solution from different starting configurations.
-The nStarts
argument allows to specify how many random starts are conducted.
-
-
-
-
Value
-
-
Returns an RStoolbox::unsuperClass object, which is a list containing the kmeans model ($model) and the raster map ($map).
-For output = "classes", $map contains a SpatRaster with discrete classes (kmeans clusters); for output = "distances" $map contains
-a SpatRaster, with 'nClasses' layers, where each layer maps the euclidean distance to the corresponding class centroid.
-
-
-
-
Examples
-
-
## Not run:
-##D library(terra)
-##D input <- rlogo
-##D
-##D ## Plot
-##D olpar <- par(no.readonly = TRUE) # back-up par
-##D par(mfrow=c(1,2))
-##D plotRGB(input)
-##D
-##D ## Run classification
-##D set.seed(25)
-##D unC <- unsuperClass(input, nSamples = 100, nClasses = 5, nStarts = 5)
-##D unC
-##D
-##D ## Plots
-##D colors <- rainbow(5)
-##D plot(unC$map, col = colors, legend = FALSE, axes = FALSE, box = FALSE)
-##D legend(1,1, legend = paste0("C",1:5), fill = colors, title = "Classes", horiz = TRUE, bty = "n")
-##D
-##D ## Return the distance of each pixel to each class centroid
-##D unC <- unsuperClass(input, nSamples = 100, nClasses = 3, output = "distances")
-##D unC
-##D
-##D ggR(unC$map, 1:3, geom_raster = TRUE)
-##D
-##D par(olpar) # reset par
-## End(Not run)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/validateMap.html b/validateMap.html
deleted file mode 100644
index 9a811c1..0000000
--- a/validateMap.html
+++ /dev/null
@@ -1,157 +0,0 @@
-R: Map accuracy assessment
-
-
-
-
-
-
-
-
-
-
-
-
-
-
validateMap {RStoolbox} R Documentation
-
-
Map accuracy assessment
-
-
Description
-
-
validate a map from a classification or regression model. This can be useful to update the accuracy assessment after filtering, e.g. for a minimum mapping unit.
-
-
-
-
Usage
-
-
validateMap(
- map,
- valData,
- responseCol,
- nSamplesV = 500,
- mode = "classification",
- classMapping = NULL
-)
-
-
-
-
Arguments
-
-
-map
-
-RasterLayer or SpatRaster. The classified map.
-
-valData
-
-sf object with validation data (POLYGONs or POINTs).
-
-responseCol
-
-Character. Column containing the validation data in attribute table of valData
.
-
-nSamplesV
-
-Integer. Number of pixels to sample for validation (only applies to polygons).
-
-mode
-
-Character. Either 'classification' or 'regression'.
-
-classMapping
-
-optional data.frame with columns 'class'
and 'classID'
defining the mapping from raster integers to class names.
-
-
-
-
-
Value
-
-
Returns a structured list includng the preformance and confusion-matrix of your then validated input data
-
-
-
-
Examples
-
-
library(caret)
-library(terra)
-
-## Training data
-poly <- readRDS(system.file("external/trainingPolygons.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")
-
-
## 01:39:45 | Begin sampling training data
-
-
## 01:39:45 | Starting to fit model
-
-
## 01:39:45 | Starting spatial predict
-
-
## ******************** Model summary ********************
-
-
## Maximum Likelihood Classification
-##
-## 251 samples
-## 7 predictor
-## 4 classes: 'cleared', 'fallen_dry', 'forest', 'water'
-##
-## No pre-processing
-## Resampling: Cross-Validated (5 fold)
-## Summary of sample sizes: 201, 201, 201, 200, 201
-## Resampling results:
-##
-## Accuracy Kappa
-## 0.996 0.9945887
-##
-## [[1]]
-## TrainAccuracy TrainKappa method
-## 1 0.996 0.9945887 custom
-##
-## [[2]]
-## Cross-Validated (5 fold) Confusion Matrix
-##
-## (entries are average cell counts across resamples)
-##
-## Reference
-## Prediction cleared fallen_dry forest water
-## cleared 14.0 0.0 0.2 0.0
-## fallen_dry 0.0 8.2 0.0 0.0
-## forest 0.0 0.0 13.8 0.0
-## water 0.0 0.0 0.0 14.0
-##
-## Accuracy (average) : 0.996
-
-
## ******************** 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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-
diff --git a/writeSLI.html b/writeSLI.html
deleted file mode 100644
index 7be4fd0..0000000
--- a/writeSLI.html
+++ /dev/null
@@ -1,122 +0,0 @@
-R: Write ENVI spectral libraries
-
-
-
-
-
-
-
-
-
-
-
-
-
-
writeSLI {RStoolbox} R Documentation
-
-
Write ENVI spectral libraries
-
-
Description
-
-
Writes binary ENVI spectral library files (sli) with accompanying header (.sli.hdr) files OR ASCII spectral library files in ENVI format.
-
-
-
-
Usage
-
-
writeSLI(
- x,
- path,
- wavl.units = "Micrometers",
- scaleF = 1,
- mode = "bin",
- endian = .Platform$endian
-)
-
-
-
-
Arguments
-
-
-x
-
-data.frame with first column containing wavelengths and all other columns containing spectra.
-
-path
-
-path to spectral library file to be created.
-
-wavl.units
-
-wavelength units. Defaults to Micrometers. Nanometers is another typical option.
-
-scaleF
-
-optional reflectance scaling factor. Defaults to 1.
-
-mode
-
-character string specifying output file type. Must be one of "bin"
for binary .sli files or "ASCII"
for ASCII ENVI plot files.
-
-endian
-
-character. Optional. By default the endian is determined based on the platform, but can be forced manually by setting it to either "little" or "big".
-
-
-
-
-
Details
-
-
ENVI spectral libraries with ending .sli are binary arrays with spectra saved in rows.
-
-
-
-
Value
-
-
Does not return anything, write the SLI file directly to your drive for where your specified your path parameter
-
-
-
-
See Also
-
-
readSLI
-
-
-
-
Examples
-
-
## 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)
-
-
-
-
[Package
RStoolbox version 0.4.0
Index ]
-
-