I was trying to do some edge enhancement on sentinel-2 satellite image, but the problem is that the console keep stating that the layer 'Cannot provide a palette when visualizing more than one band', even though i already chose a band.
Here are the script that i used:
/**
* Function to mask clouds using the Sentinel-2 QA band
* @param {ee.Image} image Sentinel-2 image
* @return {ee.Image} cloud masked Sentinel-2 image
*/
//Selecting Sentinel Image with cloud masking
function maskS2clouds(image) {
var qa = image.select('QA60');
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
var dataset = ee.ImageCollection('COPERNICUS/S2_SR').select('B8')
.filterDate('2019-09-01', '2019-10-01')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
.map(maskS2clouds);
var visualization = {
min: 0.0,
max: 0.3,
bands: ['B4', 'B3', 'B2']
}
//Using mosaic
var imageCollection = ee.ImageCollection("COPERNICUS/S2");
var image = ee.Image(imageCollection
.filterDate('2019-09-01', '2019-10-1')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
.map(maskS2clouds)
.mosaic());
// Define a "fat" Gaussian kernel.
var fat = ee.Kernel.gaussian({
radius: 3,
sigma: 3,
units: 'pixels',
normalize: true,
magnitude: -1
});
// Define a "skinny" Gaussian kernel.
var skinny = ee.Kernel.gaussian({
radius: 3,
sigma: 1,
units: 'pixels',
normalize: true,
});
// Compute a difference-of-Gaussians (DOG) kernel.
var dog = fat.add(skinny);
// Compute the zero crossings of the second derivative, display.
var zeroXings = image.convolve(dog).zeroCrossing();
Map.setCenter(101.68287285738528,0.6988384299139916, 16);
Map.addLayer(zeroXings.updateMask(zeroXings), {palette: 'FF0000'}, 'zero crossings');
But if I chose more than 1 band, then the console will state that 'Pattern 'QA60' did not match any bands.'
'Pattern 'QA60' did not match any bands.' is solved, but the problem rooted back to 'zero crossings: Layer error: Image.visualize: Cannot provide a palette when visualizing more than one band.'