ExportRasterFunctionTemplate
Summary
The ExportRasterFunctionTemplate function exports a raster function template that is associated with a raster object, or a raster function chain, applied on a raster as a raster function template.
Discussion
The function allows you to save a raster function template that has been attached to a raster object. The format of the raster function template is a .json or .xml file.
The function also allows you to save a raster function chain that has been applied to a raster object on the fly.
You can use the exported raster function template on other rasters to apply the same operations.
Syntax
ExportRasterFunctionTemplate(raster_function, path, {format})
| Parameter | Explanation | Data Type |
|---|---|---|
|
raster_function |
The raster function that will be exported. |
Dictionary |
|
path |
The output path for the raster function template. |
String |
|
format |
Specifies the format of the output raster function template.
The default value is JSON. |
String |
Code sample
Exports an existing raster function template from a raster object.
# Import system modules
import arcpy
from arcpy.ia import ExportRasterFunctionTemplate
# Open the raster object
raster_with_rft = r"C:\raster_rft.tif"
# Get the raster function template to be exported
rft = raster_with_rft.functions[1]
# Export the raster function template as a json file
ExportRasterFunctionTemplate(rft , r"C:\exported_rft.rft.json", 'JSON')
Exports a raster function chain that has been applied on a raster object.
# Import system modules
import arcpy
from arcpy.ia import NDVI, ExportRasterFunctionTemplate
# Open the raster object
raster = r"C:\raster.tif"
# Apply some raster function to the raster object
ndvi_raster = arcpy.ia.NDVI(raster, nir_band_id=5, red_band_id=3)
# Get the raster function template to be exported
rft = ndvi_raster.functions[0]
# Export the raster function chain as a raster function template as a xml file
ExportRasterFunctionTemplate(rft , r"C:\exported_rft.rft.xml", 'XML')