1

I've just started working with Google Earth Engine and, while running some tests, I stumbled into this problem. If you initialize an imageCollection and print it, the console gives you something like this:

ImageCollection (200 elements)
type: ImageCollection
bands: []
features: List (200 elements)
  0: Image LANDSAT/LT05/C01/T1_SR/LT05_191028_20080526 (6 bands)
   type: Image
   id: LANDSAT/LT05/C01/T1_SR/LT05_191028_20080526
   version: 1521654404763968
   bands: List (6 elements)
   properties: Object (22 properties)
  1: Image LANDSAT/LT05/C01/T1_SR/LT05_191028_20080611 (6 bands)
  2: Image LANDSAT/LT05/C01/T1_SR/LT05_191028_20080627 (6 bands)
  3: Image LANDSAT/LT05/C01/T1_SR/LT05_191028_20080713 (6 bands)
  4: Image LANDSAT/LT05/C01/T1_SR/LT05_191028_20080729 (6 bands)
  .
  .

and so on and so forth. However, if I try to map a .multiply() or a .divide() function over the collection and print it, I lose all informations on the images. Let's say I want to rescale the collection pixel values, my code will be:

var scaledCollection = collection.map(
    function(img) {
      return img.multiply(0.0001);
    });

print(scaledCollection);

The output in the console becomes:

ImageCollection (200 elements)
type: ImageCollection
bands: []
features: List (200 elements)
  0: Image (6 bands)
   type: Image
   bands: List (6 elements)
   properties: Object (19 properties)
  1: Image (6 bands)
  2: Image (6 bands)
  3: Image (6 bands)
  4: Image (6 bands)
  .
  .

Among other things, the properties lost are system:asset_size, system:footprint and system:time_start. Since the object structure remains the same (ImageCollection), why do some properties disappear if the only thing that I'm doing is iterate a map algebra operation over a collection?

Thanks in advance.

1 Answer 1

2

You can copy them to the new image using:

newImg.copyProperties(oldImg, img.propertyNames())

Applied to your example:

var scaledCollection = collection.map(
    function(img) {
      return img.multiply(0.0001).copyProperties(img, img.propertyNames());
    });

print(scaledCollection);

I can only speculate that properties are not maintained because it cannot be assumed that they still apply or are correct. Suppose you multiply two Landsat Images from adjacent paths together - the time, footprint, and other metadata regarding sun angle, etc are no longer correct. I understand your case is a simple scalar operation, but the .multiply() image method does not know that (it could be the former case).

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.