0

I am trying to acquire MODIS NDVI (MOD13Q1 v061) time series using Google Earth Engine for certain locations for which I have the coordinates. My code looks as follows:

////////// Input

// Specify dataset
var dataset = 'MODIS/061/MOD13Q1';

// Specify variable name
var variable = 'NDVI';

// Specify scale factor
var scale = 0.0001;

// Specify the date range of interest
var startDate = '2010-01-01';
var endDate = '2022-12-31';

// Specify a list of sites with names and coordinates
var sites = [
  {'name': 'AAC001', 'lat': 59.664, 'lon': 10.762},
  {'name': 'WUC002', 'lat': 50.505, 'lon': 6.331}
];

////////// Processing

// Load the image collection
var collection = ee.ImageCollection(dataset)
                 .filterDate(startDate, endDate)
                 .select(variable);

// Define projection of the image collection
var projection = collection.first().projection();

// Loop over the sites and export the time series as a CSV file for each site
sites.forEach(function(site) {
  
  // Create a point geometry from the coordinates
  var point = ee.Geometry.Point(site.lon, site.lat).transform(projection);

  // Filter the image collection based on the point geometry
  var collectionPoint = collection.filterBounds(point);

  // Get the value for point for each image in the collection
  var timeseries = collectionPoint.map(function(image) {
    var mean = image.reduceRegion({
      reducer: ee.Reducer.mean(),
      geometry: point,
      scale: scale,
      crs: projection,
      maxPixels: 1e9,
    });
    return image.set(variable, mean.get(variable));
  });

  // Export the time series as a CSV file
  Export.table.toDrive({
    collection: timeseries,
    description: dataset.replace(/\//g, '_') + '_' + variable + '_' + site.name,
    fileFormat: 'CSV'
  });
});

However, I get the following error:

Error: Error in map(ID=2010_02_18): Image.reduceRegion: Unable to transform geometry into requested projection. (Error code: 3)

  • I tried out a different projection (EPSG:4326), but this gives the same error.
  • I tried out shortening the temporal frame, as the product is available from 2000-02-18 to 2023-06-10, but this gives the same error.
  • I tried out adding a buffer around the points, but this gives the same error.
  • I tried out avoiding the reprojection, but this gives the same error.

1 Answer 1

0

Numerous issues:

  1. "scale" always means meters in Earth Engine. You've specified a scale of 0.0001 meters. That's probably not what you meant, and it exceeds the geometry precision available. Use something meaningful.

  2. ee.Geometry.Point takes a list of coordinates, you've specified them as separate arguments.

  3. There's absolutely no reason to call transform() on the point. Just leave it off.

https://code.earthengine.google.com/512e7d348fb576800a83833419a2e50a

1

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.