panSharpen | R Documentation |
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)
panSharpen(img, pan, r, g, b, pc = 1, method = "brovey", norm = TRUE)
img |
SpatRaster. Coarse resolution multispectral image |
pan |
SpatRaster. High resolution image, typically panchromatic. |
r |
Character or Integer. Red band in |
g |
Character or Integer. Green band in |
b |
Character or Integer. Blue band in |
pc |
Integer. Only relevant if |
method |
Character. Choose method from c("pca", "ihs", "brovey"). |
norm |
Logical. Rescale pan image to match the 1st PC component. Only relevant if |
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.
pan-sharpened SpatRaster
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
## Plot
ggRGB(lowResImg, stretch = "lin") + ggtitle("Original")
ggRGB(lowResImg_pan, stretch="lin") + ggtitle("Pansharpened (Brovey)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.