ArcGIS Raster Functions
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.4, or ArcGIS for Server 10.4.
- 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.
<local-folder>/setup.pywith 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
functionsin 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.
Raster Function Templates
- 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
Scientific Computing in Python
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.
Featured Raster Functions and Templates
Normalized Difference Vegetation Index
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
methodparameter controls whether the output NDVI raster contains raw, scaled, or color-mapped values.
- 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.
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
unitscontrols whether the air temperature values are assumed to be in Celsius or Fahrenheit.
HeatIndex.rft.xml is a grouping raster function template. The
unitsparameter remains unmodified by the template and defaults to
Learn more about Heat Index on Wikipedia.
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
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
rastersrepresenting an array of rasters. The
methodstring parameter enables a user or template to choose the specific operation (from
Maximum) to perform. The parameter defaults to
Sum. 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
Deviation from Mean
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.
Select By Pixel Size
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
thresholdparameter 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
Convert Per Second to Per Month
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
utilsmodule. 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.
Fish Habitat Suitability
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
depthparameter from a specific field (
StdZ, if available) in the table.
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.
AspectSlope.rft.xml accepts the elevation input raster and creates aspect slope map raster for visualization.
Topographic c-correction is used to remove the effects of hillshade on multispectral images. It reduces the effects of reflectance variability in areas of high or rugged terrain, thus improving the consistency of the multispectral image pixel values and the quality of images as additional processing is applied. There are many different topographic correction algorithms. These algorithms have been compared by Ion Sola et. al (2016) and the c-correction proposed in Teillet, Guindon, and Goodenough (1982) was ranked as one of the best topographic correction methods.
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
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.