Geographic Information Systems Asked on July 18, 2021
I’m trying to simplify the system:index property of an ImageCollection
containing Landsat 5, 7, and 8, images. Because collections are merged, they get 1_
, prefixes in system:index
. I’m sure that system:index
is unique, so I’m trying to remove the prefixes using the following code:
Collection = Collection.map(function(image){return image.set("system:index",image.getString('system:index').replace('(d_){1,2}L','L'))})
but it doesn’t seem to do anything. I understand that system:index
, must be unique, and it is. Regardless, I would expect an error, if it’s not unique, and not, not being allowed to modify it.
If I try to set a different property, in the same way, it works as expected, so the problem seems to be setting "system:index"
. Is it completely forbidden to modify "system:index"
? Why doesn’t it yield an error then? I couldn’t find anything in the documentation about system:index
being read-only.
// Works as expected, i.e. the SATELLITE property is changed correctly
Collection = Collection.map(function(image){return image.set("SATELLITE",image.getString('system:index').replace('(d_){1,2}L','L'))})
You can't change system:index with a mapped function, but you can set system:id which might meet your needs. It's used in preference to system:index in some situations (like when printing in the console).
If that doesn't do what you want, then you'll need to convert the collection to a list, map over that to set system:index (which doesn't have any special meaning in the context of a list), and then convert back to an ImageCollection.
Correct answer by Noel Gorelick on July 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP