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.
<local-folder>/setup.py
with administrator privileges.templates
and functions
in their own subfolders.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:
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 to Fahrenheit
.
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. The method
string parameter enables a user or template to choose the specific operation
(from Sum
, Average
, Standard Deviation
, Minimum
, and 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 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.
AspectSlope.py generates an aspect slope map i.e. simultaneously shows the aspect (direction) and slope in degree (steepness) for a terrain or other continuous surface.
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
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.