1

I saw an answer here saying that we should sort by 'system:time_start' but shouldn't that refer to the date (like 2015-05-01) instead of hour of the day? I also tried something like ee.Filter.calendarRange(7, 15, 'hour') but it didn't seem to work.

2 Answers 2

1

About using ee.Filter.calendarRange() - you might have expected that images in certain location will be coming at different hours. In many areas, it's not a case. Also,ee.Filter.calendarRange() is way to go (you should avoid using .sort as suggested in other example for many reasons).

In the example below all the images for given locations were taken between ~10:38-10:41.

I've added an example of using ee.Filter.calendarRange(), showing that it does what it is expected to do.

var l8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2"),
    geometry = /* color: #d63000 */ee.Geometry.Point([-1.6843750000000135, 31.62971723875741]);
    
var ic = l8.filterBounds(geometry)

print("Size of filtered image collection", ic.size())

// What time of the day images were taken?
print("SCENE_CENTER_TIME histogram", ic.aggregate_histogram("SCENE_CENTER_TIME"))

print("Filter includes 10am", ic.filter(ee.Filter.calendarRange(10,17,"hour")).size())
print("Filter excludes 10am", ic.filter(ee.Filter.calendarRange(11,17,"hour")).size())

Here is the link to the example: https://code.earthengine.google.com/005c8c3616ee0371b6cdf9597d91f095

Next time include an example script illustrating what didn't work for you.

I hope, it helps. Good luck with your analysis!

1
  • Thanks a bunch! It really helps! Apr 28, 2022 at 20:36
0

You can use the SUN_ELEVATION property to filter out daytime Landsat images in Earth Engine. Night images will have a negative sun elevation indicating that the sun was below the horizon at the acquisition time. Other properties like SCENE_CENTER_TIME and methods like filterDate and ee.Filter.calendarRange are based on UTC time, making it difficult to find nighttime images across different time zones.

Note that night images are almost always excluded from Level 2 and Tier 1 collections, so a collection like Tier 2 TOA is usually the best choice.

Here's a quick demo script that loads a night image and visualizes the thermal IR band:

// Select images where the sun is below the horizon
var night_images = l8
  .filterBounds(geometry)
  .filter(ee.Filter.lt("SUN_ELEVATION", 0));

var image = night_images.first()

// Print the local time of the image acquistion
print(image.date().update({timeZone: "America/Los_Angeles"}));

// Add the thermal infrared band to the map with a custom color palette
var magma = ['000004', '2C105C', '711F81', 'B63679', 'EE605E', 'FDAE78', 'FCFDBF'];
Map.addLayer(image, {min: 285, max: 295, bands: ["B11"], palette: magma});

Thermal infrared Landsat imagery over Los Angeles

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.