// Define the area of interest (AOI) - Shandong, China var aoi = ee.Geometry.Rectangle([115.5, 34.5, 122.5, 38.5]); // Load Sentinel-2 data var sentinel2 = ee.ImageCollection('COPERNICUS/S2') .filterBounds(aoi) .filterDate('2015-01-01', '2015-12-31') .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20)) .select(['B4', 'B8']); // Calculate NDVI var addNDVI = function(image) { var ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI'); return image.addBands(ndvi); }; var sentinel2WithNDVI = sentinel2.map(addNDVI).select('NDVI'); // Composite the collection to get median value var sentinel2Composite = sentinel2WithNDVI.median().clip(aoi); // Display the results Map.centerObject(aoi, 8); Map.addLayer(sentinel2Composite, {bands: ['NDVI'], min: 0, max: 1}, 'Sentinel-2 NDVI'); // Export the NDVI results to Google Drive Export.image.toDrive({ image: sentinel2Composite.select('NDVI'), description: 'Sentinel2_NDVI_Shandong_2015', scale: 1000, region: aoi, maxPixels: 1e13 });