Apply a colormap renderer to a raster.
Use case
A colormap renderer transforms pixel values in a raster to display raster data based on specific colors, aiding in visual analysis of the data. For example, a forestry commission may want to quickly visualize areas above and below the tree-line line occurring at a know elevation on a raster containing elevation values. They could overlay a transparent colormap set to color those areas below the tree-line elevation green, and those above white.
How to use the sample
Pan and zoom to explore the effect of the colormap applied to the raster.
How it works
To apply a ColormapRenderer
to a RasterLayer
:
- Create a
Raster
from a raster file. - Create a
RasterLayer
from the raster. - Create an
IEnumerable<Color>
representing colors. Colors at the beginning of the list replace the darkest values in the raster and colors at the end of the list replaced the brightest values of the raster. - Create a
ColormapRenderer
with the color list:ColormapRenderer(colors)
, and apply it to the raster layer withrasterLayer.Renderer = colormapRenderer
.
Relevant API
- Basemap
- ColormapRenderer
- Map
- MapView
- Raster
- RasterLayer
Offline data
About the data
The raster used in this sample shows an area in the south of the Shasta-Trinity National Forest, California.
Tags
colormap, data, raster, renderer, visualization
Sample Code
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.RasterColormapRenderer.RasterColormapRenderer"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
</Grid>
</ContentPage>