1

I am trying to get the time series for different points of interest, but I can only get one point location. Many of the examples that are on the web use points that are created during the code but in my case, I uploaded them from a shp file and not sure if that is the problem. Regarding that, I have noticed that is taking too long to compute, is there any other method in case the points to compute are too much? This is the code so far: https://code.earthengine.google.com/3a88da917a801be33638a6fb83829624

Map.addLayer(table);
Map.centerObject(table,8);
var studyArea = ee.FeatureCollection(table).geometry();
print (studyArea);
var buffer = studyArea.buffer(500);
print(buffer);
// Add the buffer as a layer on the map
Map.addLayer(buffer, {}, 'Buffer');

// Function to remove cloud and snow pixels
function maskCloudAndShadows(image) {
  var cloudProb = image.select('MSK_CLDPRB');
  var snowProb = image.select('MSK_SNWPRB');
  var cloud = cloudProb.lt(5);
  var snow = snowProb.lt(5);
  var scl = image.select('SCL'); 
  var shadow = scl.eq(3); // 3 = cloud shadow
  var cirrus = scl.eq(10); // 10 = cirrus
  // Cloud probability less than 5% or cloud shadow classification
  var mask = (cloud.and(snow)).and(cirrus.neq(1)).and(shadow.neq(1));
  return image.updateMask(mask);
}

var sentinel_S2 = ee.ImageCollection("COPERNICUS/S2_SR");//HARMONIZED

var s2a = sentinel_S2.filterBounds(studyArea)
        .filterDate('2020-01-01','2023-02-28')
        //.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 50))
        .map(maskCloudAndShadows)
    //.filter(ee.Filter.bounds(points));

print('filtered_S2', s2a);
print('filtered_S2 size',s2a.size());

var s2a_median = s2a.median()
                    .clip(buffer);

Map.addLayer(s2a_median,VisParam,'true Color');

function radiometric_scale(image) {
  image =  ee.Image(image.multiply(0.0001).copyProperties(image, ['system:time_start']));
  var ndwi = image.normalizedDifference(['B3', 'B8']).rename('ndwi');
  var ndvi = image.normalizedDifference(['B8', 'B4']).rename('ndvi');
  var ndti = image.normalizedDifference(['B11', 'B12']).rename('ndti');
  var ndci = image.normalizedDifference(['B5','B4']).rename('ndci');
  var RED = image.select('B4');
  var NIR = image.select('B8');
  var spm = NIR.divide(RED).rename('spm');
  return image.addBands([ndwi, ndvi, ndti, ndci,spm]).updateMask(ndwi.gt(0.12));
}

var with_indices = s2a.map(radiometric_scale);
var s2a_median = with_indices.median()
                             .select(['ndwi', 'ndvi', 'ndti', 'ndci','spm'])
                             .clip(buffer);
print(s2a_median);
Map.addLayer(s2a_median,{},'Indexes');


var chart = ui.Chart.image.seriesByRegion({
    imageCollection: with_indices.select('ndvi'),
    regions: studyArea,
    reducer: ee.Reducer.mean()
});
print(chart);
0

1 Answer 1

0

I don't know how many points do you have but, I created two arbitrary points in your roi where ndvi is not masked. So, by using as regions your variable studyArea, I got following result:

enter image description here

In your roi, there is not segregated any area because the problem is probably related with your regions parameter. You are defining studyArea as follows and it is a Multipart geometry.

var studyArea = ee.FeatureCollection(table).geometry();

Defining studyArea as follows (for avoiding issues with buffer layer):

var studyArea2 = table;

after running the complete code in the GEE code editor, the new result is segregating each region as expected:

enter image description here

Your Answer

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

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