View on GitHub Sample viewer app

Apply an RGB renderer to a raster layer to enhance feature visibility.

Image of RGB renderer

Use case

An RGB renderer is used to adjust the color bands of a multispectral image. Remote sensing images acquired from satellites often contain values representing the reflection of multiple spectrums of light. Changing the RGB renderer of such rasters can be used to differentiate and highlight particular features that reflect light differently, such as different vegetation types, or turbidity in water.

How to use the sample

Choose one of the stretch parameter types. The other options will adjust based on the chosen type. Add your inputs and click the ‘Update’ button to update the renderer.

How it works

  1. Create a Raster from a multispectral raster file.
  2. Create a RasterLayer from the raster.
  3. Create a Basemap from the raster layer and instantiate an ArcGISMap with it.
  4. Create a RGBRenderer, specifying the StretchParameters and other properties.
  5. Set the renderer on the raster layer with rasterLayer.setRasterRenderer(renderer).

Relevant API

  • Basemap
  • Raster
  • RasterLayer
  • RGBRenderer
  • StretchParameters

About the data

The raster used in this sample shows an area in the south of the Shasta-Trinity National Forest, California.

Tags

analysis, color, composite, imagery, multiband, multispectral, pan-sharpen, photograph, raster, spectrum, stretch, visualization

Sample Code

module-info.java module-info.java RgbRendererController.java RgbRendererSample.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.rgb_renderer {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.rgb_renderer to javafx.fxml;
exports com.esri.samples.rgb_renderer;
}