0

When I run the following code, a blank image is outputted.

coordinates = input()
geoCoordinates = json.loads(coordinates)
i_date = '1972-07-25'
f_date ='2022-12-31'
aoi = ee.Geometry.Polygon(geoCoordinates)
images = ee.ImageCollection("LANDSAT/LC09/C02/T2").filterBounds(aoi).filterDate(i_date, f_date)
image = ee.Image(images.first()).clipToBoundsAndScale(aoi)
url = image.select("B4").getThumbURL()
disp.Image(url = url, width = 800)

enter image description here

Does anyone know why and how I can fix this?

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Nov 22, 2022 at 22:13

1 Answer 1

0

First, you need to use var in order to introduce new variable into to GEE. Second, you used getThumbURL without providing visualization parameters. These include dimension, region, and format of your image. Also you could use extra visualization parameters defined in ee.data.getMapId. Third, I suggest using collection 2, Tier 1, level 2 or level 1 since they are Landsat data with the highest quality.

Also, you need to use print in order to see the link in your GEE console. Your syntax is not reproducible. Here I provide the one that you can check on your machine.

Last point, there is a function prepSrL8 I used for choosing Landsat scenes based on their quality (QA bands).

var i_date = '1972-07-25'
var f_date ='2022-12-31'

var aoi = ee.Geometry.MultiPoint([
[46.72759630878907,38.171211790897694],
[48.38103869160157,38.171211790897694],
[48.38103869160157,39.25559070083476],
[46.72759630878907,39.25559070083476],
[46.72759630878907,38.171211790897694]
  ]).bounds()
Map.centerObject(aoi, 8)
Map.addLayer(aoi, {}, 'Area of Interest')

var images = ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
            .map(prepSrL8)
            .filterBounds(aoi)
            .filterDate(i_date, f_date)


var image = ee.Image(images.first()).clip(aoi); print (image)
Map.addLayer(image.select('SR_B4'),{min: 0, max: 0.25})

var gifParams = {
  'region': aoi.buffer(2000).bounds(),
  'dimensions': 1024,
  'bands': "SR_B4",
  'min': 0,
  'max': 0.25,
  'format': 'jpg'
};

var url = image.getThumbURL(gifParams)
print(url)


function prepSrL8(image) {
  // Develop masks for unwanted pixels (fill, cloud, cloud shadow).
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0);
  var saturationMask = image.select('QA_RADSAT').eq(0);

  var optical = image.select("SR_B.").multiply(0.0000275).add(-0.2)
  var thermal = image.select("ST_B.*").multiply(0.00341802).add(149)
      // Approximate 0 to 1 range.
      .subtract(270)//.divide(50)

  // Replace original bands with scaled bands and apply masks.
  return image.addBands(ee.Image.cat(optical, thermal), null, true)
    .updateMask(qaMask).updateMask(saturationMask);
}
2
  • 1
    Thank you so much! This makes a lot of sense!!
    – user215516
    Commented Nov 24, 2022 at 20:28
  • My pleasure. If you get your answer, you could click on the tick bottom so others could be informed about this.
    – rez
    Commented Nov 25, 2022 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.