Geographic Information Systems Asked by mikejwilliamson on January 3, 2021
I have a function that takes an ImageCollection and sets a mean value as a property for another ImageCollection.
var DHW = HS_SSTA_7d.map(function(im) {
var res = im.reduceRegion(ee.Reducer.mean(), reefs_500, 500);
// calc mean to be called and set as property
return im.set("sst_mean", res.get("sst"))});
I then use this to filter out values great than 1 from my ImageCollection.
var DHW_non_null = DHW.filter(ee.Filter.notNull(["sst_mean"]))
.filterMetadata("sst_mean", "greater_than", 1);
Is there a way of setting the band value as a property without reducing it, so it can be filtered? Basically I want to remove any images/pixels which are great than one. I tried to set the band as a property using the two methods below but it didn’t seem to work.
var DHW = HS_SSTA_7d.map(function(im) {
return im.set("sst_mean", im.get("sst"))});
var DHW1 = ee.ImageCollection(HS_SSTA_7d_AsAList.map(function(im){
var sst = ee.Image(im).get('sst');
return ee.Image(im).set("sst_mean", sst);
}));
Is the right way of doing things, or is there a way of filtering your data without setting the band values as a property? A link to my full code ishere
Yes, you can store an image (with one band or more) as a property,
var image = ee.Image.constant(1);
print(image.set('foo', image));
but this will not allow you to filter a collection on pixel values; every filter either includes or excludes the entire image based on simple value (string/number) or geometry characteristics, not pixels.
If you want to remove individual pixels whose values are greater than one, then you can do that with masking.
var noPixelsGreaterThanOne = collection.map(function (image) {
return image.updateMask(image.select('sst').lte(1));
});
This will remove the pixel (in all bands) wherever the 'sst' band of that image is greater than one. If you then, for example, mosaic the collection processed this way, then the mosaic will use only the values that weren't masked away; the same applies to a mean or any other reduction.
Correct answer by Kevin Reid on January 3, 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