3

I have created a feature collection of burned area in the Amazon according to 1-degree grid cells over 20 years. Here is a link to the collection - https://code.earthengine.google.com/?asset=users/stavo/FCburn

In this collection, features are the grid cells, columns names are dates.

In order to create a time-lapse video, I would like to create an image collection where each image is a representation of all features and 1 column(month).

I manage to create the wanted image for 1 month with the following code:

var Jan2015 = FCburn.select('2005_01_01_BurnDate')
                    .reduceToImage(['2005_01_01_BurnDate'], ee.Reducer.first())
                    .clip(borderB)

However, I can't manage to figure out how I would iterate through each column in the collection to create an image collection. I could not find an example of a function that iterates through columns rather than features in a feature collection. How would you go about solving this issue?

1 Answer 1

3

If I understand correctly, the code below could help:

var properties = FCburn.first().propertyNames().sort().slice(0, -3)
var col = ee.ImageCollection(properties.map(function(property) {
  return FCburn.select([property])
    .reduceToImage([property], ee.Reducer.first())
    .clip(borderB)
    .set('Date', ee.Date(ee.String(property).slice(0, 10).replace('_', '-', 'g')))
 }))

The first line is to get all properties (columns) of every feature in FCburn. sort and slice methods are used to make sure the list does not include unwanted columns (ID, burnAreaProp, and system:index).

The rest of the code is to create an image collection according to what you described in your question.

4
  • Hi Kevin, I can't say I understand exactly what the function is doing, but it works! Only thing is, I would like to preserve the property name in the image collection, so I would know what date the image is from. Right now I can only see Image 1 Image to etc.
    – Stavo
    Jun 1, 2020 at 14:38
  • @Stavo, I added one more line to set a Date attributes for each image. You may want to set system:time_start attribute (the default time attribute in GEE) instead of Date.
    – Kevin
    Jun 1, 2020 at 14:54
  • As far as I know, we cannot set a name for an image. But this does not mean there's no way to distinguish them. We can easily set any attribute to an image, like I set Date attribute in the example code. Then you can filter the image of interest from image collection using filterMetadata.
    – Kevin
    Jun 1, 2020 at 15:21
  • I was thinking to preserve the date so I could later add it to each layer of the gif. However, using the .getVideoThumbURL I can not generate a decent gif, due to the size of the image collection and the size of the region. Thank you for your help anyway!
    – Stavo
    Jun 1, 2020 at 17:43

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.