I am trying to filter imported AIS data (https://marinecadastre.gov/AIS/) by time, as ground truth for ship detection using SAR images. The imported CSV stores the date in a column ["BaseDateTime"], which can be shown in the bottom image and GEE code link. The format seems to be yyyy-MM-dd'T'HH:mm:ssZ.

My problems are the following:

  1. GEE doesn't let me simply filter something in a "column" that isn't a "property" of a FeatureCollection
  2. The "BaseDateTime" values are not in ee.Date format, so reducing by column is difficult.

How do I select the AIS points that would correspond to the time a SAR image was taken?

enter image description here

Link Code: https://code.earthengine.google.com/ec4c3c9f7f983cc99ed3daee44f47bf5

//SAR Data
var dataset = ee.ImageCollection('COPERNICUS/S1_GRD')
                  .filterDate('2020-06-30', '2020-07-01')
                  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
                  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                  // Filter to get images collected in interferometric wide swath mode.
                  .filter(ee.Filter.eq('instrumentMode', 'IW'));

var listOfImages = dataset.toList(dataset.size()); // 29 images


//Importing Feature Collection 

var ais = ee.FeatureCollection('users/sheilababer/AIS_2020_06_30').filterBounds(roi);


//Treating "BaseDateTime" as a Property yields errors: 

var dayRange = ee.Number(0.08) //wanting the AIS data to be within 2 hours of SAR

var feats = ais.map(function(feat){
  feat = ee.Feature(feat);
  var date = ee.Date(feat.get('BaseDateTime'));
  var dateRange = ee.DateRange(date.advance(-(dayRange/2), 'day'), date.advance(dayRange/2, 'day'));
  var image = dataset.filterDate(dateRange).mean();
  var data = image.reduceRegion(ee.Reducer.first(), feat.geometry(), 500);
  return ee.Feature(feat.setMulti(data))

var date_col = ['BaseDateTime']

//Trying to reduce the feature collection by column also yields errors,
//probably because date is parsed as a string:

  reducer: ee.Reducer.mean(),
  selectors: ['BaseDateTime'],


1 Answer 1


Your collections aren't shared, but because those dates are in ISO format, you can simply filter the strings:

var ais = ee.FeatureCollection('users/sheilababer/AIS_2020_06_30')
    .filter('BaseDateTime > '2020-06-30' && BaseDateTime < '2020-07-01'")

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.