Identify raster cell

View inQMLC++
View on GitHub
Sample viewer app

Get the cell value of a local raster at the tapped location and display the result in a callout.

screenshot

Use case

You may want to identify a raster layer to get its exact cell value in case the approximate value conveyed by its symbology is not sufficient. The information available for the raster cell depends on the type of raster layer being identified. For example, a 3-band satellite or aerial image might provide 8-bit RGB values, whereas a digital elevation model (DEM) would provide floating point z values. By identifying a raster cell of a DEM, you can retrieve the precise elevation of a location.

How to use the sample

Tap on the raster or press on the raster, hold, and move around the raster to identify it and see the raster cell attributes information displayed in a callout.

How it works

  1. Connect to signals emmited by a mouseClicked, mousePressedAndHeld, and mouseMoved on the MapView.
  2. On tapped or pressed, held, and dragged:

    • Call identifyLayer(...) passing in the raster layer, screen point, tolerance, whether to return popups only, and maximum number of results per layer.
    • Connect to the identifyLayerCompleted to get the result of the identify and then get the GeoElement from the layer result and get any RasterCells from them.
    • Create a callout at the calculated map point and populate the callout content with text from the RasterCell attributes.
    • Show the callout.

Relevant API

  • GeoView::identifyLayer(...)
  • IdentifyLayerResult
  • RasterCell
  • RasterCell::attributes
  • RasterLayer

Offline data

Read more about how to set up the sample's offline data here.

Link Local Location
South Africa data <userhome>/ArcGIS/Runtime/Data/raster/SAEVI8Day_03May20

About the data

The data shown is an NDVI classification derived from MODIS imagery between 27 Apr 2020 and 4 May 2020. It comes from the NASA Worldview application. In a normalized difference vegetation index, or NDVI, values range between -1 and +1 with the positive end of the spectrum showing green vegetation.

Tags

band, cell, cell value, continuous, discrete, identify, pixel, pixel value, raster

Sample Code

IdentifyRasterCell.qmlIdentifyRasterCell.cppIdentifyRasterCell.h
                                                             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// [WriteFile Name=IdentifyRasterCell, Category=Layers]
// [Legal]
// Copyright 2020 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.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.12

Item {

    // add a mapView component
    MapView {
        id: view
        anchors.fill: parent

        Callout {
            id: callout
            calloutData: view.calloutData
            accessoryButtonHidden: true
            calloutContent: customComponent
            leaderHeight: 30
        }


        Component {
            id: customComponent

            Text {
                id: customComponentText
                text: view.calloutData.detail

                Binding {
                    target: callout
                    value: contentHeight + callout.calloutFramePadding
                    property: "calloutHeight"
                }

                wrapMode: Text.WordWrap
            }
        }
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    IdentifyRasterCellSample {
        id: model
        mapView: view
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.