Skip to main content

ExportRasterFunctionTemplate

汇总

ExportRasterFunctionTemplate 函数用于导出栅格函数模板,该模板与栅格对象或栅格函数链相关联,并作为栅格函数模板应用于栅格。

讨论

该函数可以保存已附加到栅格对象的栅格函数模板。 栅格函数模板的格式为 .json.xml 文件。

该函数还可以保存动态应用于栅格对象的栅格函数链。

您可以在其他栅格上使用导出的栅格函数模板来应用相同的操作。

语法

ExportRasterFunctionTemplate(raster_function, path, {format})

参数 说明 数据类型

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.

  • JSON—The output format will be JSON.

  • XML—The output format will be XML.

(默认值为 JSON)

String

代码示例

ExportRasterFunctionTemplate 示例 1

从栅格对象导出现有栅格函数模板。

# 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')
ExportRasterFunctionTemplate 示例 2

导出已应用于栅格对象的栅格函数链。

# 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')