I'm building a javascript/Typescript/Angular application to view digital elevation model (DEM) data. The source data are Cloud-Optimized Geotiffs (COGs), which are brought in as an ImageryTileLayer with a RasterStretchRenderer.
To render them, I want users to have the following color ramp controls:
I think it would be useful to have a way to put a hold on the dynamicRangeAdjustment so that, when turned off, it would preserve the current color ramp settings. However, I can't seem to find where those min/max values are being computed or stored.
Suppose the min/max of the overall dataset is 150.512 m and 401.768 m. These values are accessible via the layer.serviceRasterInfo.statistics[0] object. The renderer.customStatistics[0] object is also usable when I want to set a manual min/max (e.g. 250 m and 310 m). I can toggle the DynamicRangeAdjustment on, which then works normally. When DynamicRangeAdjustment is turned off, though, it reverts to the dataset min/max (or, if I set it, my custom min/max). I'm looking for a way to pull the current values for min/max that DynamicRangeAdjustment is working with, which I will then feed into the custom min/max. Is that possible, and if so, how?
Hi there,
You can use the ImageryTileLayer.fetchPixels method to retrieve information about pixels within the extent. From the returned PixelBlock, you can then access the min and max pixel values through its statistics property.
const pixelBlock = await layer.fetchPixels(view.extent, view.width, view.height);
// access pixelBlock.statistics (minValue and maxValue)