Apply raster function to raster from service

View inMAUIUWPWPFWinUIView on GitHub

Load a raster from a service, then apply a function to it.

Image of apply raster function to raster from service

Use case

Raster functions allow processing operations that can be applied to one or more rasters on the fly. Functions can be applied to rasters that come from a service. A land survey agency may apply hillshade and aspect functions to rasters with elevation data in order to better determine the topography of a landscape and to make further planning decisions.

How to use the sample

The raster function is applied automatically when the sample starts and the result is displayed.

How it works

  1. Create the ImageServiceRaster referring to the image server URL.
  2. Create the RasterFunction from a JSON string.
  3. Get the name of the raster argument to the function with rasterFunction.Arguments.GetRasterNames().First()
  4. Set the raster argument with rasterFunction.SetRaster(rasterName, imageServiceRaster).
  5. Create a new Raster referring to the raster function.
  6. Create a RasterLayer to visualize the computed raster.
  7. Display the raster.

Relevant API

  • ImageServiceRaster
  • Raster
  • RasterFunction
  • RasterFunctionArguments
  • RasterLayer

About the data

The sample applies a hillshade function to a raster produced from the National Land Cover Database, NLCDLandCover2001. You can learn more about the hillshade function in the ArcMap documentation.

Additional information

The raster function computation happens locally on the client device.

Tags

function, layer, raster, raster function, service

Sample Code

RasterLayerRasterFunction.xamlRasterLayerRasterFunction.xamlRasterLayerRasterFunction.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<UserControl
    x:Class="ArcGIS.UWP.Samples.RasterLayerRasterFunction.RasterLayerRasterFunction"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:esri="using:Esri.ArcGISRuntime"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <esriUI:MapView x:Name="MyMapView"/>
    </Grid>
</UserControl>

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