You can mosaic a collection of pan-sharpened images as follows:
// Function to mask clouds using the quality band of Landsat 8.
var maskL8 = function(image) {
var qa = image.select('BQA');
/// Check that the cloud bit is off.
// See https://landsat.usgs.gov/collectionqualityband
var mask = qa.bitwiseAnd(1 << 4).eq(0);
return image.updateMask(mask);
};
// HSV-based Pan-Sharpening of Landsat 8 TOA images.
var panSharpenL8 = function(image) {
var rgb = image.select('B4', 'B3', 'B2');
var pan = image.select('B8');
// Convert to HSV, swap in the pan band, and convert back to RGB.
var huesat = rgb.rgbToHsv().select('hue', 'saturation');
var upres = ee.Image.cat(huesat, pan).hsvToRgb();
return image.addBands(upres);
};
// Map the function over one year of Landsat 8 TOA data and take the median.
var composite = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate('2016-01-01', '2016-12-31')
.map(maskL8)
.map(panSharpenL8)
.median();
// There are many fine places to look; here is one. Comment
// this out if you want to twiddle knobs while panning around.
Map.setCenter(-59.61577, 6.80943, 15);
// Display before and after layers using the same vis parameters.
Map.addLayer(composite, {bands:['B4', 'B3', 'B2'], max: 0.3}, 'Original');
Map.addLayer(composite, {bands:['red','green','blue'], max: 0.3}, 'Pansharpened');
Code link: https://code.earthengine.google.com/269648d7ecc77d2491e3b3513f7ed3f4
Note that the preceding code is a combination of the CloudMasking/Landsat8TOAReflectanceQABand.js and Image/HSVPanSharpening.js examples.
While you could apply the panSharpen
function to a previously mosaicked image and get results, that approach does not make physical sense to me because the high and low spatial resolution data in the mosaic might have been collected at different times/dates.
Best Answer
Panchromatic images are created when the imaging sensor is sensitive to a wide range of wavelengths of light, typically spanning a large part of the visible part of the spectrum. Here is the thing, all imaging sensors need a certain minimum amount of light energy before they can detect a difference in brightness. If the sensor is only sensitive (or is only directed) to light from a very specific part of the spectrum, say for example the blue wavelengths, then there is a limited amount of energy available to the sensor compared to a sensor that samples across a wider range of wavelengths. To compensate for this limited energy availability, multi-spectral sensors (the kind that create red, green, blue, near infrared images) will typically sample over a larger spatial extent to get the necessary amount of energy needed to 'fill' the imaging detector. Thus, multispectral band images will typically be of a coarser spatial resolution than a panchromatic image. There is a trade-off that is made between the spectral resolution (i.e. the range of wavelengths that are sampled by an imaging detector) and the spatial resolution. This is why commercial satellites like Ikonos and Geoeye will commonly provide three or more relatively coarse resolution multispecral bands along with a finer spatial resolution panchromatic band. Importantly, there exists a kind of compromise here in which you can combine the fine spatial resolution of a pan image with the high spectral resolution of multi-spectral bands. This is what is known as panchromatic sharpening and it is commonly used to compensate for the spectral/spatial compromise in satellite imaging.
Incidentally, this is also the reason why bands of multi-spectral imagery taken in longer wavelengths, e.g. short-wave infrared, tend to be sampled over much wider ranges of wavelengths compared to the visible bands. The amount of reflected and emitted electromagnetic energy bouncing around out there is uneven and the sun emits a peak around the visible part. Once you get into the short-wave infrared, there is far less energy around to sample compared to shorter-wavelength visible light, so the detectors have to be sensitive to a wider range. If you take a look at Landsat 8, as an example, the SWIR2 band 7 actually samples a wider range of wavelengths than its panchromatic band.