0

I got the following error message after trying to import cloud-free Sentinel-2 imagery for a polygon area covering the entire Tiwi Islands, Australia.

true-colour image: Layer error: internal error

// Filter to only include images intersecting Tiwi.

var polygon = ee.Geometry.Polygon({
  coords: [[
[129.90415998438357,-12.027354108834277], [131.63999982813357,-12.027354108834277],
[131.63999982813357,-11.101721188177093], [129.90415998438357,-11.101721188177093], 
[129.90415998438357,-12.027354108834277]]],
  geodesic: false
});

//  Define the image collection we are working with by writing this command
    var image = ee.Image(sent2

    // filter to get only images in the date range we are interested in
    .filterDate("2018-09-01", "2018-11-30")

    // sort the collection by a metadata property, in our case cloud cover is a very useful one
    .sort("CLOUD_COVERAGE_ASSESSMENT")

    // select the first image out of this collection - i.e. the most cloud free image in the date range
    .first());

    // print the image to the console.
    print("A Sentinel-2 scene:", image);

    // Define visualization parameters in a JavaScript dictionary for true colour rendering. Bands 4,3 and 2 needed for RGB.
    var trueColour = {
        bands: ["B4", "B3", "B2"],
        min: 0,
        max: 3000
        };

  // Add the image to the map, using the visualization parameters.
  Map.addLayer(image, trueColour, "true-colour image");
1

If you are using a polygon of the study area, use it for filtering. Also, the island is too big for 1 single image:

enter image description here

But, you can mosaic the date of less cloud of the entire study area (in this case I use the above scene to extract the date):

//  Define the image collection we are working with by writing this command
    var image = ee.Image(sent2

    // filter to get only images in the date range we are interested in
    .filterDate("2018-09-07", "2018-09-08")

    // filter by polygon
    .filterBounds(polygon)

    // filter by orbit number
    .filterMetadata('SENSING_ORBIT_NUMBER','equals',31)

    // sort the collection by a metadata property, in our case cloud cover is a very useful one
    .sort("CLOUD_COVERAGE_ASSESSMENT")

    // select the first image out of this collection - i.e. the most cloud free image in the date range
    .mosaic());

enter image description here

Or apply a reducer (I suggest you min or median):

//  Define the image collection we are working with by writing this command
    var image = ee.ImageCollection(sent2

    // filter to get only images in the date range we are interested in
    .filterDate("2018-09-01", "2018-11-30")

    // filter by polygon
    .filterBounds(polygon)

    // filter by orbit number
    .filterMetadata('SENSING_ORBIT_NUMBER','equals',31)

    // sort the collection by a metadata property, in our case cloud cover is a very useful one
    .sort("CLOUD_COVERAGE_ASSESSMENT")

    // select the first image out of this collection - i.e. the most cloud free image in the date range
    .min());

enter image description here

|improve this answer|||||
  • Thanks so much! that works well. Is it also possible to create a mosaic of all the images in the entire date range with <10% cloud cover for instance? – user3444391 Aug 28 '19 at 21:45
  • Yes, using .filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10) – aldo_tapia Aug 28 '19 at 22:05
  • Also, how did you use the above scene to extract the date? – user3444391 Oct 12 '19 at 8:38

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.