Class RasterLayer

All Implemented Interfaces:
TimeAware, LayerContent, Loadable

public final class RasterLayer extends ImageAdjustmentLayer implements TimeAware
A layer that can visualize raster data (from a raster data source).

In its simplest form, raster data consists of a matrix of cells (or pixels) organized into rows and columns (or a grid) where each cell contains a value representing information. Raster layer can support these main types of raster data sources:

You can change how a raster layer is visualized by creating a RasterRenderer and applying it to the layer. Each raster layer supports identify on its individual cells when it is displayed in a MapView or SceneView. The raster layer adopts the loadable pattern; many of its properties are initialized asynchronously. See Loadable for more information.

If a raster dataset has just one value associated with each cell it is called a single-band raster. For example, in a digital elevation model (DEM) each cell contains one value representing the elevation at that location.

A satellite image, however, commonly has multiple bands representing different wavelengths of the electromagnetic spectrum. Landsat imagery, for example, contains seven bands that represent data from the visible and infrared parts of the spectrum. Rasters are particularly useful for remote sensing tasks, such as monitoring vegetation and seeing through smoke to analyze an active fire.

Raster datasets can be quite large. The size of the dataset depends on the following:

  • The geographic extent of the data.
  • The size of the cells used (resolution).
  • The number of bands.
As with any data consumed locally, file size can be an issue for storage as well as for transferring datasets over the network.

Example for working with a Raster Layer


 Raster raster = new Raster("absolute-file-path-of-raster");

 RasterLayer rasterLayer = new RasterLayer(raster);

 rasterLayer.addDoneLoadingListener(() -> {
   if (rasterLayer.getLoadStatus() == LoadStatus.LOADED) {
     // raster layer has loaded
   }
 });

 ArcGISMap map = new ArcGISMap();
 map.getOperationalLayers().add(rasterLayer);

 mapView = new MapView();
 mapView.setMap(map);
 
The layer is loaded when displayed in a MapView; if using the layer without a MapView, call the Layer.loadAsync() method. Use the layer done loading event to determine when the layer is ready, and check the loaded status before using the layer.
Since:
100.0.0
See Also:
  • Constructor Details

    • RasterLayer

      public RasterLayer(Raster raster)
      Creates a raster layer from the specified raster data source.
      Parameters:
      raster - raster data source
      Throws:
      IllegalArgumentException - if raster is null
      Since:
      100.0.0
    • RasterLayer

      public RasterLayer(PortalItem portalItem)
      Creates a raster layer from the specified image service portal item.
      Parameters:
      portalItem - a portal item of type PortalItem.Type.IMAGE_SERVICE.
      Throws:
      IllegalArgumentException - if portalItem is null
      Since:
      100.2.0
  • Method Details

    • getRaster

      public Raster getRaster()
      Returns the raster data source for this layer.
      Returns:
      the raster used by this raster layer
      Since:
      100.0.0
    • setRasterRenderer

      public void setRasterRenderer(RasterRenderer rasterRenderer)
      Sets the raster renderer used for this layer.
      Parameters:
      rasterRenderer - the rasterRenderer to set
      Throws:
      IllegalArgumentException - if rasterRenderer is null
      Since:
      100.0.0
    • copy

      public RasterLayer copy()
      Creates a deep copy of this RasterLayer instance.
      Returns:
      a deep copy of this RasterLayer instance, which means that copies of all fields of this layer are made including its loading state
      Since:
      100.1.0
    • getRasterRenderer

      public RasterRenderer getRasterRenderer()
      Gets the raster renderer used for this layer.
      Returns:
      the raster renderer
      Since:
      100.0.0
    • getFullTimeExtent

      public TimeExtent getFullTimeExtent()
      Description copied from interface: TimeAware
      Returns the full time extent of the object. Will be null if the object is not time aware.
      Specified by:
      getFullTimeExtent in interface TimeAware
      Returns:
      the time extent, or null if the object is not time aware
    • getTimeInterval

      public TimeValue getTimeInterval()
      Description copied from interface: TimeAware
      Returns the suggested time slider step size for this time aware object. Can be null if no time interval is suggested for this time aware object.
      Specified by:
      getTimeInterval in interface TimeAware
      Returns:
      the time interval, or null if there is no time interval
    • getTimeOffset

      public TimeValue getTimeOffset()
      Description copied from interface: TimeAware
      Returns the time offset applied to this object. The offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared.
      Specified by:
      getTimeOffset in interface TimeAware
      Returns:
      the time offset, or null if no offset has been set
    • isTimeFilteringEnabled

      public boolean isTimeFilteringEnabled()
      Description copied from interface: TimeAware
      Returns whether or not the object must use the time extent defined on the owning GeoView to filter its data.
      Specified by:
      isTimeFilteringEnabled in interface TimeAware
      Returns:
      true if time filtering is enabled; otherwise false
    • setIsTimeFilteringEnabled

      public void setIsTimeFilteringEnabled(boolean enabled)
      Description copied from interface: TimeAware
      Enables or disables whether the object must use the time extent defined on the owning GeoView to filter its data.
      Specified by:
      setIsTimeFilteringEnabled in interface TimeAware
      Parameters:
      enabled - true to enable time filtering; otherwise false
    • isTimeFilteringSupported

      public boolean isTimeFilteringSupported()
      Description copied from interface: TimeAware
      Returns whether or not the object supports filtering its contents by time values with the extent set on the owning GeoView.
      Specified by:
      isTimeFilteringSupported in interface TimeAware
      Returns:
      true if time filtering is supported; otherwise false
    • setTimeOffset

      public void setTimeOffset(TimeValue timeOffset)
      Description copied from interface: TimeAware
      Sets a time offset for this object. The time offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared. Can be null if there is no time offset.
      Specified by:
      setTimeOffset in interface TimeAware
      Parameters:
      timeOffset - the time offset, or null if there is no time offset
    • addFullTimeExtentChangedListener

      public void addFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
      Description copied from interface: TimeAware
      Adds a listener that will fire when there is a change to the full time extent.
      Specified by:
      addFullTimeExtentChangedListener in interface TimeAware
      Parameters:
      listener - the listener to add
    • removeFullTimeExtentChangedListener

      public boolean removeFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
      Description copied from interface: TimeAware
      Removes a full time extent changed listener.
      Specified by:
      removeFullTimeExtentChangedListener in interface TimeAware
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was removed, otherwise false