0

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.'

Braiam
  • 1
  • 11
  • 47
  • 78
Noob123
  • 23
  • 2
  • 5
  • Sorry, some correction, if I add a band the console will state that 'Pattern 'QA60' did not match any bands.' i seek enlightment – Noob123 Jul 22 '20 at 04:24
  • I've never used any of the tech here, but are the error messages not quite self explanatory? To add corrections, use the EDIT button under the question rather than posting a comment that doesn't obviously associate with anything – Caius Jard Jul 22 '20 at 04:36
  • @CaiusJard Yes, i know the error messages is trying to knock some senses into my script, but i can't find where and i've been trying to add it here and there to no avail. Also yes you're right, there's actually an edit button, being an idiot is hard.... thank you for the corrections! – Noob123 Jul 22 '20 at 04:43
  • Ok, so pattern QA60 doesn't match any bands, probably means you can't use QA60 at the top, if you need to match bands? And the one where you get an error where you try to match multiple bands, means you can only use a single band (looks like you specified 3?) – Caius Jard Jul 22 '20 at 05:37
  • @CaiusJard Oh right, the first 3 bands that i use was for visualization purpose on the different layer than the one that I'm trying to classify. Also that one stupid error where I can't use 'Q60' was already solved, but still the problem is back to 'zero crossings: Layer error: Image.visualize: Cannot provide a palette when visualizing more than one band.'. Thank you once again for pointing it out! – Noob123 Jul 22 '20 at 06:15

0 Answers0