2

I am trying to visualize NDVI for a specific boundary that I have imported from ArcMap. When I filter the NAIP imagery by the boundary it works perfectly, but when I try and filter the MODIS by the boundary I only receive an output of the NDVI values for the entire dataset (world). This causes problems later on when I need to use the .map function to add the 'NDVI' band to the clipped Naip imagery.

Below is a segment of my code where geom references the imported polygon.

I am new to Google Earth Engine.

var geom = table2 
var naip = ee.ImageCollection("USDA/NAIP/DOQQ")
  .filterDate('2011-07-03','2011-08-12')
  .filterBounds(geom);
Map.addLayer(naip);
var mod = ee.ImageCollection("MODIS/006/MOD13A2")
  .filterDate('2011-07-03','2011-08-12')
  .filterBounds(geom)
  .select('NDVI'); 
Map.addLayer(mod);  
1

You can use ee.ImageCollection.mosaic() to convert your image collection to an image, and ee.Image.clip() to clip the image to a specified geometry/polygon. For example:

// Define an example geometry.
var geom = ee.Geometry.Point(-121.646, 43.762).buffer(1e4);
Map.centerObject(geom);

var naip = ee.ImageCollection("USDA/NAIP/DOQQ")
  .filterDate('2011-07-03','2011-08-12');
Map.addLayer(naip.mosaic().clip(geom), {}, 'naip');

var mod = ee.ImageCollection("MODIS/006/MOD13A2")
  .filterDate('2011-07-03','2011-08-12')
  .select('NDVI'); 
Map.addLayer(mod.mosaic().clip(geom), {min:0, max:10000}, "modis"); 

Note that .filterBounds() is not needed if all you are going to do is visualize the results, although it doesn't hurt to include it.

  • Thanks! Is there a way to do this without buffering a point? I imported a polygon boundary I would like to clip the image to. – Lydia Keenan Oct 22 at 13:42

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.