import RasterStretchRenderer from "@arcgis/core/renderers/RasterStretchRenderer.js";const RasterStretchRenderer = await $arcgis.import("@arcgis/core/renderers/RasterStretchRenderer.js");- Inheritance:
- RasterStretchRenderer→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.12
RasterStretchRenderer defines the symbology with a gradual ramp of colors for each pixel in a ImageryLayer, ImageryTileLayer, and WCSLayer based on the pixel value. The RasterStretchRenderer works well when you have a large range of values to display, such as in imagery, aerial photographs, or elevation models.
The stretch renderer allows you to define the range of values to be displayed and apply a ColorRamp to those values.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
| | ||
declaredClass readonly inherited | ||
| | ||
number[] | | |
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
type readonly | "raster-stretch" | |
| |
colorRamp
The stretched values are mapped to this specified color ramp.
The color ramp algorithm must set when using this renderer, otherwise the cie-lab AlgorithmicColorRamp.algorithm
used by default.
- See also
customStatistics
- Type
- RasterBandStatistics[] | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.31
The input band statistics can be specified through the customStatistics property. If not specified,
they will be retrieved from the data. If dynamicRangeAdjustment is true, these values will be ignored.
Examples
for single band stretchconst bandStat = layer.rasterInfo.statistics[0];const renderer = new RasterStretchRenderer();renderer.stretchType = "min-max";renderer.customStatistics = [{ min: valueSlider.values[0], max: valueSlider.values[1], avg: bandStat.avg, stddev: bandStat.stddev}];for RGB (e.g. layer.bandIds = [3,2,1])const stats = layer.rasterInfo.statistics;const bandIds = layer.bandIds;const renderer = new RasterStretchRenderer();renderer.stretchType = "min-max";renderer.customStatistics = [{ min: redSlider.values[0], max: redSlider.values[1], avg: stats[bandIds[0]].avg, stddev: stats[bandIds[0]].stddev,}, { min: greenSlider.values[0], max: greenSlider.values[1], avg: stats[bandIds[1]].avg, stddev: stats[bandIds[1]].stddev,}, { min: valueSlider.values[0], max: valueSlider.values[1], avg: stats[bandIds[2]].avg, stddev: stats[bandIds[2]].stddev}]; dynamicRangeAdjustment
- Type
- boolean
When Dynamic Range Adjustment is true, the statistics based on the current display extent
are calculated as you zoom and pan around the image. This property only applies to images in
2D MapView.
- Default value
- false
gamma
- Type
- number[]
The gamma values to be used if useGamma is set to true.
Gamma refers to the degree of contrast between the mid-level gray values of a raster dataset.
Gamma does not affect the black or white values in a raster dataset, only the middle values.
By applying a gamma correction, you can control the overall brightness of a layer.
Gamma stretching is only valid with the none, standard-deviation, and min-max stretch types.
maxPercent
Applicable when stretchType is percent-clip.
Specifies the percentage of the highest values to exclude from the stretch.
minPercent
Applicable when stretchType is percent-clip.
Specifies the percentage of the lowest values to exclude from the stretch.
numberOfStandardDeviations
Applicable when stretchType is standard-deviation.
Specifies the number of standard deviations to use. The values beyond the number of standard deviations
become the outputMin and outputMax. The remaining values are linearly stretched
between outputMin and outputMax.
sigmoidStrengthLevel
The sigmoid strength level determines how much of the sigmoidal function will be used in the stretch. A low value such as 1 will only use the middle portion of the curve, which tends to produce dull and faint colors. A high value such as 6 will use the entire curve, which tends to produce bold and sharp colors.
stretchType
- Type
- RasterStretchType
The stretch type defines a histogram stretch that will be applied to the rasters to enhance their appearance. Stretching improves the appearance of the data by spreading the pixel values along a histogram from the minimum and maximum values defined by their bit depth. For example, an 8-bit raster dataset or mosaic dataset will be stretched from 0 to 255. Different stretches will produce different results in the raster display.
The possible stretch types are listed below.
| Value | Description |
|---|---|
| none | No stretch method will be applied, even if statistics exist. |
| standard-deviation | This stretch type applies a linear stretch between the values defined by the standard deviation value. |
| histogram-equalization | The pixel values are stretched to adjust the contrast using the histogram of the data. |
| min-max | This stretch type applies a linear stretch based on the output minimum and output maximum pixel values, which are used as the endpoints for the histogram. |
| percent-clip | This stretch type applies a linear stretch between the defined minPercent and maxPercent pixel values. |
| sigmoid | The Sigmoid contrast stretch is designed to highlight moderate pixel values in your imagery while maintaining sufficient contrast at the extremes. |
- Default value
- "none"
Methods
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
clone
- Signature
-
clone (): RasterStretchRenderer
Creates a deep clone of the renderer.
- Returns
- RasterStretchRenderer
A deep clone of the object that invoked this method.
Example
// Creates a deep clone of the first layer's rendererlet renderer = view.map.layers.at(0).renderer.clone(); toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.