Geographic Information Systems Asked on June 26, 2021
I have two images, high1 and low1. Pixels in high1 represent high areas. Pixels in low1 represent low areas.
I would like to create a new image that has a band with a flag for low and high areas. I would like the flag for low areas to be values of 10 and the flag for high areas to be values of 100. This new band would consist of all the pixels of high1 and low 1 and each pixel in that band has a value of 100 or 10.
Does anyone know how to accomplish this in Google Earth Engine or the GEE package in r (rgee)? I think this needs to be done through an image function.
In following script, I used a dem image imported from my assets where I arbitrarily assigned a threshold of 2000 m for separating high and low areas. These images (high1 and low1) were used to create a new image that has a band with a flag for low and high areas (with values of 10 and 100; respectively).
var image = ee.Image("users/joseguerreroa/raster_files_utah/utah_demUTM12");
var imageVisParam = {"opacity":1,"bands":["b1"],"min":1366,"max":3397,"gamma":1};
print(image);
var bounds = ee.Geometry.Polygon(ee.Geometry(image.get('system:footprint'))
.coordinates());
Map.addLayer(image, imageVisParam, 'image');
Map.centerObject(image);
var minValue = image.rename('min')
.reduceRegion(ee.Reducer.min(), bounds);
print("min", minValue.get('min'));
var maxValue = image.rename('max')
.reduceRegion(ee.Reducer.max(), bounds);
print("max", maxValue.get('max'));
var high1 = image.gt(2000).multiply(100).rename('high area').selfMask();
var imageVisParam2 = {"opacity":1,"bands":["high area"],"palette":["0c08ff"]};
Map.addLayer(high1, imageVisParam2);
var low1 = image.lte(2000).multiply(10).rename('low area').selfMask();
var imageVisParam3 = {"opacity":1,"bands":["low area"],"palette":["orange"]};
Map.addLayer(low1, imageVisParam3);
var new_image = low1.addBands(high1);
var imageVisParam4 = {"opacity":1,"bands":["low area"],"palette":["red"]};
Map.addLayer(new_image, imageVisParam4);
var imageVisParam5 = {"opacity":1,"bands":["high area"],"palette":["green"]};
Map.addLayer(new_image, imageVisParam5);
print(new_image);
After running above script in GEE console editor, it can be observed as follow that new image has two bands (low and high area) as expected.
Answered by xunilk on June 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP