I am trying to display a ROI (region of interest) on the GEE map. I am getting pretty odd outputs like this:

enter image description here

Code that generated this image is down below:

var geometry = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-74.17301042227143, 41.01676815108097],
      [-75.15079362539643, 40.93797200093739],
      [-74.50260026602143, 40.3084072747414],
      [-73.63468034414643, 40.559275861105796]]]);

var landsat = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")


var area = ee.FeatureCollection(geometry);

var image = ee.Image((landsat)
    .filterDate('2018-01-01', '2018-12-31')
var filteredimage = image
Map.addLayer(filteredimage, {bands: ['B4', 'B3', 'B2'], max: 0.5, gamma: 2}, 'Better L8 Image');

If I uncomment the .clip(area) line, I get only the intersection of these two chunks. But what I want is to show only the red section. And show all of it. From what I understand is the these square pictures are the raw pictures of the satellite. But how can I crop an image out of two or more different satellite images?

1 Answer 1


By using .first(), you are asking for only the first (here, least cloudy) image from the LANDSAT/LC08/C01/T1_TOA that matches your other filters. Generally, when you want images from an area, you should use an operator like .mosaic() (prefer the last available image, but on a pixel-by-pixel basis — useful when sorted by date) or .median() (take the median of all images).


var image = ee.Image((landsat)
    .filterDate('2018-01-01', '2018-12-31')
var filteredimage = image.clip(geometry);
Map.addLayer(filteredimage, {bands: ['B4', 'B3', 'B2'], max: 0.5, gamma: 2}, 'Better L8 Image');


I've also simplified your code a couple of ways:

  • There is no need for var area = ee.FeatureCollection(geometry); — none of what you're doing requires a collection.
  • There is no need for .select(['B[1-7]']) — the band selection you are doing in addLayer suffices to control which pixels get computed, so the .select() is redundant.
  • Thank you for the answer, but i still want to ask this. I want to make a timelapse about vegetation change throughout the years. It will include about 300 satellite images. If i keep the band selection option (Red Green Blue NIR) will my code be faster?
    – osbm
    Aug 30, 2021 at 11:06
  • @user9279225 I am not sure whether it will make any difference at all, but certainly not a large one.
    – Kevin Reid
    Aug 30, 2021 at 13:52

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.