Class RasterLayer
- java.lang.Object
-
- com.esri.arcgisruntime.layers.Layer
-
- com.esri.arcgisruntime.layers.ImageAdjustmentLayer
-
- com.esri.arcgisruntime.layers.RasterLayer
-
- All Implemented Interfaces:
TimeAware
,LayerContent
,Loadable
public final class RasterLayer extends ImageAdjustmentLayer implements TimeAware
Displays raster data in a map or scene.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:
- Raster files - path to a file on the device.
- Remote ArcGIS Image services, see
ImageServiceRaster
. - Raster files within GeoPackages, see
GeoPackageRaster
. - Mosaic datasets, see
MosaicDatasetRaster
.
RasterRenderer
and applying it to the layer. Each raster layer supports identify on its individual cells when it is displayed in aMapView
orSceneView
. The raster layer adopts the loadable pattern; many of its properties are initialized asynchronously. SeeLoadable
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.
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 aMapView
; if using the layer without aMapView
, call theLayer.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:
ImageAdjustmentLayer
,ImageServiceRaster
,GeoPackageRaster
,Layer
,MosaicDatasetRaster
,Raster
-
-
Constructor Summary
Constructors Constructor Description RasterLayer(PortalItem portalItem)
Creates a new RasterLayer with the provided portal item.RasterLayer(Raster raster)
Creates a new RasterLayer with the provided raster.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
Adds a listener that will fire when there is a change to the full time extent.RasterLayer
copy()
Creates a deep copy of this RasterLayer instance.TimeExtent
getFullTimeExtent()
Returns the full time extent of the object.Raster
getRaster()
Returns the raster used by this raster layer.RasterRenderer
getRasterRenderer()
Gets the raster renderer for this layer.TimeValue
getTimeInterval()
Returns the suggested time slider step size for this time aware object.TimeValue
getTimeOffset()
Returns the time offset applied to this object.boolean
isTimeFilteringEnabled()
Returns whether or not the object must use the time extent defined on the owning GeoView to filter its data.boolean
isTimeFilteringSupported()
Returns whether or not the object supports filtering its contents by time values with the extent set on the owning GeoView.boolean
removeFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
Removes a full time extent changed listener.void
setIsTimeFilteringEnabled(boolean enabled)
Enables or disables whether the object must use the time extent defined on the owning GeoView to filter its data.void
setRasterRenderer(RasterRenderer rasterRenderer)
Sets the raster renderer for this layer.void
setTimeOffset(TimeValue timeOffset)
Sets a time offset for this object.-
Methods inherited from class com.esri.arcgisruntime.layers.ImageAdjustmentLayer
getBrightness, getContrast, getGamma, setBrightness, setContrast, setGamma
-
Methods inherited from class com.esri.arcgisruntime.layers.Layer
addDoneLoadingListener, addLoadStatusChangedListener, addVisibilityChangedListener, cancelLoad, canChangeVisibility, canShowInLegend, fetchLegendInfosAsync, getAttribution, getDescription, getFullExtent, getId, getItem, getLoadError, getLoadStatus, getMaxScale, getMinScale, getName, getOpacity, getSpatialReference, getSubLayerContents, isIdentifyEnabled, isVisible, isVisibleAtScale, loadAsync, removeDoneLoadingListener, removeLoadStatusChangedListener, removeVisibilityChangedListener, retryLoadAsync, setCanShowInLegend, setDescription, setId, setMaxScale, setMinScale, setName, setOpacity, setVisible
-
-
-
-
Constructor Detail
-
RasterLayer
public RasterLayer(Raster raster)
Creates a new RasterLayer with the provided raster.- Parameters:
raster
- the raster source- Throws:
IllegalArgumentException
- if raster is null- Since:
- 100.0.0
-
RasterLayer
public RasterLayer(PortalItem portalItem)
Creates a new RasterLayer with the provided portal item.- Parameters:
portalItem
- the portal item- Throws:
IllegalArgumentException
- if portalItem is null- Since:
- 100.2.0
-
-
Method Detail
-
getRaster
public Raster getRaster()
Returns the raster used by this raster layer.- Returns:
- the raster used by this raster layer
- Since:
- 100.0.0
-
setRasterRenderer
public void setRasterRenderer(RasterRenderer rasterRenderer)
Sets the raster renderer 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 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 interfaceTimeAware
- 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 interfaceTimeAware
- 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 owningGeoView
. This allows for data from different periods of time to be compared.- Specified by:
getTimeOffset
in interfaceTimeAware
- 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 interfaceTimeAware
- 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 interfaceTimeAware
- 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 interfaceTimeAware
- 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 owningGeoView
. 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 interfaceTimeAware
- 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 interfaceTimeAware
- 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 interfaceTimeAware
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was removed, otherwise false
-
-