2

The two images below are the same.

In the images, the value of each pixel corresponds to a date in milliseconds.

enter image description here

In the top image, the pixels with the higher values - more recent date - are highlighted, while those with lower values are less highlighted.

The bottom image represents the raw mask of the image.

I imagine it is something to do with the masking of the image, but I am still figuring out what processing or operation was done to get this result.

Any ideas?

Code: https://code.earthengine.google.com/27a90e3abd360f7334ea41d0a4a9a9f6

6
  • What do you mean by highlight? Do you want a different color palette with classified pixels, where newest pixels are class, say, 3, the next oldest class is 2, and the oldest is 1?
    – John Polo
    Jan 24, 2023 at 14:13
  • Can you notice in the (smoothed) image that there is processing that makes some pixels look like dust? The lower the pixel value, the less apparent it is. As I said, I think it is something related to the masking of the image. In this case, the values should range from 0 to 1. Jan 24, 2023 at 14:23
  • Do you want just a binary mask where either a pixel is visible or it’s not?
    – John Polo
    Jan 24, 2023 at 14:44
  • No. I think the solution would not be a binary mask (0 or 1) but a mask with intermediate values. Jan 24, 2023 at 15:17
  • The values do range from 0 - 1. The faint pixels have values closer to 0. If you click over to the Inspector tab on right side of map, you can see values of pixels you click on.
    – John Polo
    Jan 24, 2023 at 18:27

1 Answer 1

1

Since you said that you tried clamp(), I'm assuming that you want the values reclassified.

var alerts = ee.ImageCollection('projects/radar-wur/raddalert/v1');
var geography = 'sa';

var latestAlert = ee.Image(
  alerts
    .filter(ee.Filter.eq('layer', 'alerts'))
    .filter(ee.Filter.eq('geography', geography))
    .sort('system:time_end', false)
    .first());

var confirmedAlertMask = latestAlert.select('Alert').eq(3);

var timeStart = ee.Date(latestAlert.get('system:time_start'));
var timeEnd = ee.Date(latestAlert.get('system:time_end'));
var differenceInDays = timeEnd.difference(timeStart, 'day');

// YYDOY (Year-Year-Day-of-Year).
var from = ee.List.sequence(0, differenceInDays).map(function(d) {
  return ee.Number.parse(
    timeStart.advance(d, 'day').format('yyDDD'))
    .subtract(1);
});

// Milliseconds.
var to = ee.List.sequence(0, differenceInDays)
  .map(function(d) {
    return timeStart.advance(d, 'day').millis();
  });

var alertInMillis = latestAlert
  .select('Date')
  // .updateMask(confirmedAlertMask)
  .remap(from, to)
  .rename('alertDate');

// Classifying, or reclassing the values.
var classValues = [0, 1, 2, 3];
var remapValues = ee.List.sequence({start:0, end:1, count:4});
var remapVal = ee.List.sequence({start: 0, end:1, count:3});
var label = 'lc';
var latestRmap = latestAlert.remap(classValues, remapValues).rename(label).toByte();

print(latestRmap, 'remap')

// Iago's original maps, alert in milliseconds
Map.addLayer(alertInMillis.updateMask(confirmedAlertMask.mask()), {}, 'Millis mask Raw');
Map.addLayer(alertInMillis.mask(), {}, 'Millis mask Smoothed');

// Iago's maps without ".mask()"
Map.addLayer(alertInMillis.updateMask(confirmedAlertMask), {}, 'Millis Raw');
Map.addLayer(alertInMillis, {}, 'Millis Smoothed');

// Alert in days, without a mask
Map.addLayer(latestAlert.updateMask(confirmedAlertMask), {}, 'No Mask Raw');
Map.addLayer(latestAlert, {}, 'No Mask Smoothed');

// Alert in days, with a mask
Map.addLayer(latestAlert.updateMask(confirmedAlertMask).mask(), {}, 'Mask Raw');
Map.addLayer(latestAlert.mask(), {}, 'Mask Smoothed');

// Original data, same as Alert in days without mask
Map.addLayer(latestAlert, {}, 'latest')

// Original data reclassed
Map.addLayer(latestRmap, {}, 'lc')
Map.setCenter(-65.81, -9.198, 8);

https://code.earthengine.google.com/5245cc7b6205254f99f3e888b785659c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.