4

importing the landsat 5 TM 32-day NDVI composite data set.

I have made it as far as drawing a polygon of my ROI and extracting from a different data set, a global land cover map (ESA/GLOBCOVER_L4_200901_200912_V2_3) which was linked from another question posted on here:

Drawing polygon and extracting land cover inside using Google Earth Engine?

I tried to reconfigure it to work with my Landsat NDVI set and I was met with errors. I tried to extract just the NDVI band and try with that, but I keep getting an error:

land.clip is not a function in , line #

var landsat: Imagecollection "Landsat 5 TM 32-Day NDVI Composite"  
var geometry: Polygon, 4 vertices  
var globcover: Image "GlobCover: GLobal Land Cover Map"

// Extract the landcover band    
var land = globcover.select('landcover');    
// Clip the image to the polygon geometry    
var landcover_roi = land.clip(geometry);  
// Add a map layer of the landcover clipped to the polygon.  
Map.addLayer(landcover_roi);

reworking to accomodate the landsat:

// Extract the landcover band  
    var land = landsat.select('NDVI');  
    // Clip the image to the polygon geometry  
    var landcover_roi = land.clip(geometry);  
    // Add a map layer of the landcover clipped to the polygon.  
    Map.addLayer(landcover_roi);

This is where I get the error,

land.clip is not a function in <global> line 4.

I am attempting to draw a polygon (square) around an area on the LS5NDVI data, export the "data cube", and correlate the time NDVI values at each pixel against various climate data to produce a single layer "heat map" of sorts to visually represent the correlation at each pixel.

2
  • It appears that you simply copied the "Imports" section of the Code Editor window, so your "landsat", "geometry", and "globcover" objects cannot be easily reproduced by others. It would be better to click on the blue "Show generated code" icon and copy the Javascript code that defines the objects into the question that you posted here. Aug 2, 2016 at 16:39
  • Hi, I see you're new to SO. If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark. This helps keep users focused on answering questions which still don't have accepted answers Jan 6, 2019 at 19:43

1 Answer 1

7

The code that you copied uses an Earth Engine object of type "Image", and Image objects have a method/function named clip. Your reworked code (i.e. Landsat) uses an Earth Engine object of type "ImageCollection", and ImageCollection objects do not have a method named clip, so it produces an error. To get around this, you can either:

  1. Convert the ImageCollection to an Image using a reducing method (i.e. median, mode, mosaic, max, etc.)
  2. Write a function that clips an Image object, and map that function over the collection using ee.ImageCollection.map().

Also, it probably doesn't make sense to add the entire Landsat 5 collection as a layer on the interactive map... it contains over 25 years of data. Add a step that filters the Landsat collection down to a shorter time interval, using ImageCollection.filterDate().

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.