Kamal Hosen
Kamal Hosen
Geospatial Developer | Data Science | Python

Sep 12, 2023

Clip Image by Feature/FeatureCollections in Google Earth Engine

/media/article-img/clip-gee.jpg

Earth engine is a powerful platform to deal with massive scale earth observation datasets. Clip is one of the useful functions in Google Earth Engine that use to clip raster image or image collections for a specific area as a feature or feature collection.

 

Here, I will show you, how we can clip the MODIS NDVI for Bangladesh.

// Load a MODIS NDVI dataset
var modisNDVI = ee.ImageCollection('MODIS/006/MOD13A2')
  .filterDate('2020-01-01', '2020-12-31')
  .select('NDVI')
  .median();

Now, we will load countries boundary feature collections available in the Earth engine and filter this dataset for Bnagladesh and finally, we will use this filtered feature to clip NDVI.

// Load the administrative boundaries of Bangladesh from GEE's built-in dataset
var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017');
var bangladesh = countries.filter(ee.Filter.eq('country_na', 'Bangladesh'));

// Clip the MODIS NDVI dataset to the Bangladesh administrative boundary
var clippedNDVI = modisNDVI.clip(bangladesh);

// Display the clipped NDVI on the map
Map.centerObject(bangladesh, 7);
Map.addLayer(clippedNDVI, {
  min: 0,
  max: 8000,
  palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']
}, 'Clipped NDVI');

 

Share To

About Author
  • Kamal Hosen
  • Kamal Hosen
    Geospatial Developer | Data Science | Python

    A passionate geospatial developer and analyst whose core interest is developing geospatial products/services to support the decision-making process in climate change and disaster risk reduction, spatial planning process, natural resources management, and land management sectors. I love learning and working with open source technologies like Python, Django, LeafletJS, PostGIS, GeoServer, and Google Earth Engine.