Raster colormap renderer

Loading

Code

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3
import Esri.ArcGISExtras 1.1

Rectangle {
    id: rootRectangle
    clip: true

    width: 800
    height: 600

    property double scaleFactor: System.displayScaleFactor
    property string dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/raster"

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            BasemapImagery {}

            onLoadStatusChanged: {
                if (loadStatus !== Enums.LoadStatusLoaded)
                    return;

                setColormap();
                operationalLayers.append(rasterLayer);
            }
        }
    }

    RasterLayer {
        id: rasterLayer

        Raster {
            path: dataPath + "/ShastaBW.tif"
        }

        onLoadStatusChanged: {
            if (loadStatus !== Enums.LoadStatusLoaded)
                return;

            mapView.setViewpointGeometryAndPadding(fullExtent, 50);
        }   
    }

    function setColormap() {

        // create a color map where values 0-150 are red and 150-250 are yellow
        var colorArray = [];
        for (var i = 0; i < 250; i++)
            colorArray.push(i < 150 ? Qt.rgba(255, 0, 0) : Qt.rgba(255,255,0));

        // create a colormap
        var colormap = ArcGISRuntimeEnvironment.createObject("Colormap", {colors: colorArray});

        // create colormap renderer
        var colormapRenderer = ArcGISRuntimeEnvironment.createObject("ColormapRenderer", {colormap: colormap});

        // apply the renderer to the raster layer
        rasterLayer.renderer = colormapRenderer;
    }
}


In this topic
  1. Code