Geographic Information Systems Asked by AndyArnell on February 14, 2021
I am exporting image assets to my google drive as GeoTiffs. Each asset was originally created by clipping an image to a feature and then reprojected to a slightly coarser resolution. Therefore when using the inspector in code editor, pixels not fully covered by the polygon have a weighted value shown in brackets after the absolute pixel value.
I am aware reductions like reduceRegions uses these weightings (unless you specify an unweighted() reduction). But I was wondering if there is a way to use the weightings when exporting an image asset to drive?
Ideally, for this analysis, if the absolute value of a pixel in code editor is 1000 and the pixel weighting shows as 50%, then the value exported to the GeoTIFF in my drive would be 500, whereas currently it seems to remain 1000.
Hopefully the description is clear enough, but say if you need a code example.
The “weightings” are known as the image's mask.
if the absolute value of a pixel in code editor is 1000 and the pixel weighting shows as 50%, then the value exported to the GeoTIFF in my drive would be 500, whereas currently it seems to remain 1000.
You can modify the pixel values in this way by exporting image.multiply(image.mask())
.
You might also want to try combining this with unmask
and updateMask
to convert to an image whose mask is always 1 (100%); this image will display within Earth Engine more like what you're wanting to export, but it won't modify anything but the mask.
Demo script:
// resample() ensures that the edges of this image will be partially masked by
// interpolation between masked and unmasked pixels, so it demonstrates the
// effects of what we're going to do to it.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_001004_20140524').resample();
// Convert the image to fully unmasked:
var unmasked = image
// Convert fully masked pixels (only) to zero.
.unmask(0, false)
// Convert partially-masked pixels (only) to fully masked pixels with the same value.
.updateMask(1);
// Multiply the unmasked image by the mask; this gives the same effect
// as mosaicing or visualizing the original masked image on top of
// a zero/black image.
var multiplied = unmasked.multiply(image.mask());
Map.setCenter(-21.85161, 78.02296, 16);
Map.addLayer(image, {}, "Original");
Map.addLayer(unmasked, {}, "Unmasked");
Map.addLayer(multiplied, {}, "Multiplied");
Map.addLayer(image.multiply(image.mask()), {}, "Multiplied w/o unmasking", false);
https://code.earthengine.google.com/287cbf2109e1b8e2ed06a9d5aa1cbb54
Correct answer by Kevin Reid on February 14, 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