1

I am working in Google Earth Engine. Is it possible to clip the Landsat scenes to the boundary of my area of interest rather than just filtering down the number of scenes to those that touch the area of interest?

I have figured out the filtering, but not how to clip. This is what my script looks like:

// Define a region of interest  (i.e. the shapefile you imported)
var roi = K2C_aoi;

// Load the Landsat 8 scaled radiance image collection.
var landsatCollection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
    .filterDate('2019-06-10', '2019-07-12')
    .filterBounds(K2C_aoi)

// Make a cloud-free composite.
var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: landsatCollection,
  asFloat: true
});

// Visualize the Composite using different spectral band combinations to help you identify object
Map.addLayer(composite, {bands: ['B4', 'B3', 'B2'], max: 0.5, gamma: 2}, 'Natural color', true);
2
  • 4
    Does this answer your question? Clipping vs Filtering Images with a Polygon - Google Earth Engine
    – Basile
    Feb 29, 2020 at 15:51
  • not quite, I am still confused. I have essentially the same question as where the link takes me. I WANT to clip my image collection so that I only see the landsat data within my shapefile boundary, but I can't figure out the script to make that happen. All I can do is filter it, which is ok, but not what I want to do.
    – rmirvine9
    Feb 29, 2020 at 16:48

1 Answer 1

3

Okay, here you are.

// Define a region of interest  (i.e. the shapefile you imported)
var roi = ee.Geometry.Rectangle([91, 53, 92, 54]);

// Load the Landsat 8 scaled radiance image collection.
var landsatCollection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
    .filterDate('2019-06-10', '2019-07-12')
    .filterBounds(roi);

// Make a cloud-free composite.
var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: landsatCollection,
  asFloat: true
});

// Clip composite to aoi
var clipped_composite = composite.clip(roi);

// Visualize the Composite using different spectral band combinations to help you identify object
Map.addLayer(clipped_composite, {bands: ['B4', 'B3', 'B2'], max: 0.5, gamma: 2}, 'Natural color', true);

// Center map on the clipped composite
Map.centerObject(clipped_composite);
1
  • 1
    thank you! I was missing the concept that the output of the composite itself is a single image rather than the collection (it's obvious now that I can see what you wrote out in the script).
    – rmirvine9
    Mar 1, 2020 at 17:37

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.