1

I want to use Landsat image from GEE with area specified within an input. But when I run the script it only shows a small part of the area (the intended area of interest is the one in blue). The code is as the following

var countries = Indonesia

var Nama_Provinsi = ['Kalimantan Selatan'] 
var geometry = countries.filter(ee.Filter.inList('NAME_1', Nama_Provinsi));
var area1 = ee.FeatureCollection(geometry);
Map.centerObject(geometry, 8);
Map.addLayer(geometry,{color:"Blue" },"Provinsi");

var L8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
var RGB_vis = {min: 0, max: 0.3, bands: ['B4', 'B3', 'B2']};
var filtered = L8
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(geometry)
.sort('CLOUD_COVER', true);
var image = ee.Image(filtered.first());
Map.addLayer(image, RGB_vis,'RGB', false );

// Compute the Enhanced Vegetation Index (EVI).
var nir = image.select('B5');
var red = image.select('B4');
var blue = image.select('B2');
var evi = image.expression(
  '2.5*(B5-B4)/(B5+6*B4-7.5*B2+1)', {
    'B5' : nir,
    'B4' : red,
    'B2' : blue
  });
// Display the result.
Map.centerObject(image, 8);
var eviPara ={min: -1, max: 1, palette: ['blue', 'white', 'green']};
Map.addLayer(evi, eviPara, 'EVI');

And the result I got is as the picture. enter image description here

1
var image = ee.Image(filtered.first());

In this line you are asking for only one image from the collection that matches your filters. To get coverage of the entire area, you must consult multiple images. A common way to do this is with the .mosaic() operation, which layers the images “on top of” each other (last on top, so most recent on top if not sorted).

var image = filtered.mosaic();

You can also use averages or other reduction operations; the median of all images in the collection is a common choice:

var image = filtered.median();

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.