Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Raster layer (service)

Sample Viewer View Sample on GitHub

Create a raster layer from a raster image service.

Use case

Accessing a raster image from an online service can be useful for analysing the most up-to-date data available for an area. For example, retrieving recent results of bathymetry surveys within a shipping channel monitored for its sediment build-up would allow planners to assess dredging needs.

How to use the sample

Simply launch the sample to see a raster from an image service being used on a map.

How it works

  1. Create an ImageServiceRaster using the service's URL.
  2. Create a RasterLayer from the image service raster.
  3. Add the raster layer the the map.

About the data

This sample uses a NOAA raster image service. The service computes a hillshade image from the depth (in meters) of U.S. coastal waters.

Relevant API

  • ImageServiceRaster
  • RasterLayer

Tags

image service, raster

Sample Code

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.9

Rectangle {
    id: rootRectangle
    clip: true

    width: 800
    height: 600

    MapView {
        anchors.fill: parent
        id: mapView

        Map {
            // create a basemap from a tiled layer and add to the map
            Basemap {
                ArcGISTiledLayer {
                    url: "https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer"
                }
            }

            // create and add a raster layer to the map
            RasterLayer {
                //! [ImageServiceRaster Create an image service raster]
                // create the raster layer from an image service raster
                ImageServiceRaster {
                    id: imageServiceRaster
                    url: "https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_hillshades/ImageServer"

                    // zoom to the center of the raster once it's loaded
                    onLoadStatusChanged: {
                        if (loadStatus === Enums.LoadStatusLoaded) {
                            const scale = 100000;
                            mapView.setViewpointCenterAndScale(ArcGISRuntimeEnvironment.createObject("Point", {x: -13643095.660131, y: 4550009.846004}), scale);
                        }
                    }
                }
                //! [ImageServiceRaster Create an image service raster]
            }
        }
    }
}