1

I have managed to export a time series of MODIS daily surface temperature pixel data from the Google earth Engine Code Editor using a combination of code scripts provided by Stack Exchange, here is the link https://code.earthengine.google.com/0949dc53da45580dfaf2131250187847. However the pixel-sized spaced points are not all inside the area of interest, I can`t figure out why and I feel maybe my exported data set includes data from outside the area of interest.

I have also managed to create another code script with the pixel-sized spaced points inside the area of interest, here is the link; https://code.earthengine.google.com/f73a5afed5e813f8b83a528303ab6506. But I can`t manage to combine both codes correctly to export a time series of daily surface temperature pixel data which has all the pixel-sized spaced points inside the area of interest.

Here is the feature collection/function code from the first link which does not have all the pixel-sized spaced points inside the area of interest;

function spacedPoints(fc, proj) {
  var latlon = ee.Image.pixelLonLat().reproject(proj);
  var coords = latlon.select(['longitude', 'latitude'])
                 .reduceRegion({reducer: ee.Reducer.toList(),
                                geometry: fc,
                                scale: proj.nominalScale().toInt()
  });
  var point_list = ee.List(coords.get('longitude')).zip(ee.List(coords.get('latitude')));
  var list = ee.List([0]);
  var feats = ee.FeatureCollection(point_list.map(function(point){
    var ind = point_list.indexOf(point);
    var feat = ee.Feature(ee.Geometry.Point(point_list.get(ind)), {'ID': ind});
    return list.add(feat);
  }).flatten().removeAll([0]));
  return feats;
}

How can I adjust the above code so that all the pixel-sized spaced points are inside the area of interest?

  • 1
    Withouth going fully going through your script, might have something to do with the pixel size of MODIS (250m) and the lat lon you derive from those pixels. Some pixels intersect with your fc geometry but have a center (e.g. the lat lon you derive) outside it? – Jobbo90 Nov 13 at 9:03
  • Great food for thought, thank you very much for your suggestions Jobbo90. – COM Nov 15 at 0:16
1

To make sure your collection of points does contain all the center of the pixels, first make a buffer around your area of interest of the size of the pixels. Afterwards, apply filterBounds() to filter out all points outside the region of interest.

Adapt the the geometry argument of reduceRegions as follows:

var coords = latlon.select(['longitude', 'latitude'])
                 .reduceRegion({reducer: ee.Reducer.toList(),
                                geometry: fc.geometry(1).buffer(proj.nominalScale().toInt()),
                                scale: proj.nominalScale().toInt()
  });

And at the last line of the spaced points function, filter out the points outside the region of interest:

return feats.filterBounds(fc.geometry(1));

I think this should return what you expected: link code

Although you could remove a lines from your code using getRegion: see this link

  • The links you have provided are excellent, thank you so much Kuik. I am currently completing my PhD and this has been a real help, thanks again. – COM Nov 15 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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