i loaded the FIRMS data in Google earth engine for the year 2018 and now want to know for a created AOI, when and if there was a fire there. My idea is to create a loop that shows me in a five-day rhythm whether there is a record in the AOI or not. Does anyone have any idea how to set up something like this?

This is the first part of my code:

//dataset of FIRMS
var FIRMS = ee.ImageCollection('FIRMS')
             .filterDate('2018-01-01', '2018-12-31');
var T21 = FIRMS.mosaic()

Assuming your aoi is stored in a variable StudyArea, something like below should work. Remember that loops in Earth Engine is achived via map() and conditionals via filter(). See this guide for more examples.

var filtered = ee.ImageCollection('FIRMS')
  .filterDate('2018-01-01', '2018-12-31')

// Create a list of start days
var dayOfYearList = ee.List.sequence(1, 365, 5)

// Function to convert day to date
var dateFromDayOfYear = function(day) {
  var dateString = ee.String('2018').cat(ee.String(ee.Number(day).toInt()))
  return ee.Date.parse('YYYYD', dateString)
// Create a list of start dates
var startDateList = dayOfYearList.map(dateFromDayOfYear)

// Function to return an image consisting of count of valid pixels in the date range
var checkDateRange = function(start) {
  var end = ee.Date(start).advance(5, 'day')
  var dateRangeFiltered = filtered.filter(ee.Filter.date(start, end))
  var pixelCount = dateRangeFiltered.reduce(ee.Reducer.count())
  // return the image with a new property for start date, so we can retrieve it later
  return pixelCount.set({start_date: start})

// Count total pixels within aoi
var totalPixelCount = function(image) {
  var countDict = ee.Image(image).reduceRegion({
    reducer: ee.Reducer.count(),
    geometry: studyArea,
    scale: 1000})
  var totalCount = countDict.get('T21_count')
  // Create a featurecollection with null geometry
  // featurecollection helps because you can filter by properties
  return ee.Feature(null, {'date': ee.Image(image).get('start_date'), 'totalCount': totalCount})

// Map the functions over all dates
var yearImages = startDateList.map(checkDateRange);
var yearCounts = ee.FeatureCollection(yearImages.map(totalPixelCount))

// Apply filter on results
var rangesWithNoFires = yearCounts.filter(ee.Filter.eq('totalCount', 0))
  • Thank you very much, it was very usefull. But how can I show the fire indicated for my StudyArea? And how do I know for which day the alarm is displayed? – Alexi Aug 26 at 7:43
  • Can you clarify what you mean by showing the fire for study area? You can print the dates for fires using aggregate_array.. see code.earthengine.google.co.in/425b5ba58baed51691363565a0387f5b – spatialthoughts Aug 26 at 14:53
  • Hello, thank you so much for your help. That was very helpful. Now that I know the date for the alarm in my StudyArea, I want Sentinel2 data always five days before and five days after the alarm. The goal is to make a comparison between NBR and FIRMS. I have already calculated the NBR for all available Sentinel2 data and attached it to the data as a new band. Is this possible? See code.earthengine.google.com/2d2c456bc3efa5ed6c0cb601aed275ac – Alexi Aug 27 at 7:37

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.