3

I have 16 points imported as an asset in GEE. Each of these points has a date property (STARTDATE) in epoch format. I am stuck at extracting this date in and using it to acquire before and after images based on this date.

Here's the code I am trying;

var point = ee.FeatureCollection("users/wawerujohn/Laikipia_Forestland_Swarms_2020");

print(point)

//Read the date of the point asset
var pointdate = point.get('STARTDATE');
print(pointdate);

var pointdate1 = point.filter(ee.Filter.date('system:properties', 'STARTDATE'));
print(pointdate1);


//Add to the map
Map.centerObject(point)
Map.addLayer(point, {}, 'Invaded') 

I have tried using the .get and filter function to extract the date but not successsful. Here is the link to the code; https://code.earthengine.google.com/760c57ea612a0649ea0d634fbed91626

1 Answer 1

2

You have this issue because you are applying 'get' method to a feature collection in a not adequate way. If you want dates for each feature you can map Feature Collection as in following script:

var points = ee.FeatureCollection("users/wawerujohn/Laikipia_Forestland_Swarms_2020");

print("points", points);

var listOfPoints = points.toList(points.size());

print("points", listOfPoints);

var dates = listOfPoints.map(function (ele){
  
  return ee.Feature(ele).get('STARTDATE');
  
});

print("dates", dates);

//Add to the map
Map.centerObject(points);
Map.addLayer(points, {}, 'Invaded');

After running above script in GEE code editor, you will have a list with 'STARTDATE' property for each point instead a null value as with your script. Result can be observed in red rectangle of following image.

enter image description here

2
  • Thanks for the explanation. It worked perfectly!
    – Shiraz
    Commented Oct 10, 2021 at 6:18
  • kindly here's a link to a follow-up question that I am facing after using solving this one. Thanks for the help with this question. I would appreciate if you could have a look at this one too gis.stackexchange.com/q/413596/181433?sem=2
    – Shiraz
    Commented Oct 10, 2021 at 19:04

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.