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