This repository houses modern image processing and analytic tools called raster functions. Raster functions are lightweight and process only the pixels visible on your screen, in memory, without creating intermediate files. They are powerful because you can chain them together and apply them on huge rasters and mosaics on the fly.
In this repository, you will find useful function chains (*.rft.xml) created by the Esri community. You can also create custom raster functions in Python that work seamlessly with the several dozen functions that ship with ArcGIS.
- Install ArcGIS for Desktop 10.3.1, or ArcGIS for Server 10.3.1.
- Install the latest release of prerequisite Python extension packages if you are setting up for the first time:
- Download Python extensions binaries.
- Unzip the contents to a temporary local folder.
- Run
<local-folder>/setup.py
with administrator privileges.
- Install the latest release of custom raster functions:
- Download all custom raster functions.
- Unzip the contents locally to a home folder.
- You'll find ready-to-use
templates
andfunctions
in their own subfolders.
- Learn more about raster functions, function chains, and templates using the Resources below.
- Learn how you can create new raster functions using the Python API.
-
- Creating new raster function templates
- Saving a function chain as a raster function template
- Applying function templates
- Editing function templates
- Resolving template variables using attribute table
- Adding a processing template to a mosaic dataset
- Configuring an image service to use a raster function template
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
-
NDVI.py serves as a reference Python rendition of the stock NDVI raster function. It accepts one multi-band raster as input, and one-based indices corresponding to the Red and Infrared bands of the input raster. An additional
method
parameter controls whether the output NDVI raster contains raw, scaled, or color-mapped values.Supporting templates:
- NDVI-Raw: Returns raw NDVI values in the range [-1.0, +1.0] as a one-band, floating-point raster.
- NDVI-Grayscale: Returns NDVI values scaled to the range [0, 200] as one-band, 8-bit raster.
- NDVI-Colormap: Returns scaled NDVI values as color-mapped raster.
Learn more about NDVI on Wikipedia or in the Documentation for ArcGIS.
-
WindChill.py computes wind chill given two rasters representing wind speed in miles-per-hour and ambient air temperature in Fahrenheit.
Windchill.rft.xml is a grouping raster function template.
Learn more about Wind Chill on Wikipedia.
-
HeatIndex.py computes apparent temperature (as perceived by us) given two rasters corresponding to ambient air temperature and relative humidity. An additional string parameter
units
controls whether the air temperature values are assumed to be in Celsius or Fahrenheit.HeatIndex.rft.xml is a grouping raster function template. The
units
parameter remains unmodified by the template and defaults toFahrenheit
.Learn more about Heat Index on Wikipedia.
-
KeyMetadata.py demonstrates how key properties can be introduced or overridden by a raster function. These are the inputs to the function:
Property Name
,Property Value
—The name and value of the dataset-level key property to update or introduce.Band Names
—Band names of the outgoing raster specified as a CSV.Metadata JSON
—Key metadata to be injected into the outgoing raster described as a JSON string representing a collection of key-value pairs. Learn more here.
This function serves as an example of one that doesn't need to implement the
.updatePixels()
method. -
MaskRaster.py enables you to apply the input mask raster as the NoData mask on the primary input raster.
MaskRaster.rft.xml is a grouping raster function template where the inputs are the primary raster and the mask raster (in that order).
-
Arithmetic.py demonstrates the application of simple arithmetic operations on two rasters. It's not meant to replace the functionality provided by the built-in Local Function or the Math toolset. You can, however, use it as a springboard to building custom mathematical or analytical operations.
-
Aggregate.py serves to demonstrates the application of simple aggregation along each pixel over a collection of overlapping rasters. The primary input to the function is of type
rasters
representing an array of rasters. Themethod
string parameter enables a user or template to choose the specific operation (fromSum
,Average
,Standard Deviation
,Minimum
, andMaximum
) to perform. The parameter defaults toSum
. The output is a raster containing values corresponding to the chosen statistic.Aggregate.rft.xml is a sample grouping raster function template with only one input: the collection of rasters to aggregate. The template leaves the
method
parameter unmodified. -
DeviationFromMean.rft.xml helps with anomaly detection by calculating the deviation of the primary raster from the mean computed over a collection of overlapping rasters. This grouping raster function template demonstrates how complex operations can be constructed by chaining simple functions. The template computes the mean over a collection of rasters using the Aggregate function and then subtracts that result from the pixels values of the primary raster.
It's interesting to note that this template could be rewritten as a single Python raster function that accepts a raster array and compute deviation from the group mean of the first (or some user-specified) raster in that group.
-
SelectByPixelSize.py accepts two overlapping rasters and a threshold value indicating the resolution at which the function switches from returning the first raster to returning the second raster as output. If unspecified, the
threshold
parameter defaults to the average cell size of the two input rasters.SelectByPixelSize.rft.xml is a grouping raster function template that accepts two rasters as input and leaves
threshold
unspecified. -
ConvertPerSecondToPerMonth.py accepts a raster containing pixels values representing observations in some units per-second, and converts it to a raster representing the observation in units per-month. For this conversion to be a accurate, the function needs to know the month associated with acquisition of the input raster. This function demonstrates effective use of key metadata in processing and analysis.
-
CompositeBands.rft.xml and CompositeBands-4Bands-Ordered.rft.xml are raster function templates that demonstrate grouping with
rasters
(an array of raster objects) and with four individual rasters, respectively. The output is a single raster generated by compositing all bands of all overlapping input rasters. The template uses the built-in composite bands raster function. -
Hillshade.py is reference Python implementation designed to emulate the built-in Hillshade raster function while serving to demonstrate effective use of SciPy, NumPy, and the helper functions implemented in the
utils
module. This is an example of a neighborhood or focal operation.The Scale-adjusted Hillshade raster function template applies hillshading on the input elevation raster with a non-linearly adjusted z-factor.
Learn more about how the hillshade algorithm works here.
-
MultidirectionalHillshade.pyd and the accompanying MultidirectionalHillshade.rft.xml raster function template applies Hillshading from multiple directions for improved visualization. Learn more here.
-
FishHabitatSuitability.py returns a raster representing suitability of fish habitat at a user-specified ocean depth given two rasters representing water temperature and salinity. This function demonstrates how raster functions can be exploited in analytic workflows.
FishHabitatSuitability.rft.xml is a grouping raster function template that accepts the temperature and salinity rasters (in that order). This template—when used in the Add Rasters to Mosaic Dataset tool with the Table raster type or as a processing template on a mosaic dataset—is capable of obtaining the value of the
depth
parameter from a specific field (StdZ
, if available) in the table. -
VineyardAnalysis.py serves to demonstrate how you can compute a suitability raster given the elevation, slope, and aspect of the region.
VineyardAnalysis.rft.xml accepts the elevation input raster and uses built-in raster functions to compute slope and elevation before feeding the output to the Vineyard Analysis raster function.
Copyright 2014 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.
A copy of the license is available in the repository's License.txt file.
[](Esri Tags: ArcGIS Raster Function Chain On-the-fly Image Processing Samples) [](Esri Language: Python)