Hello all,
I was wondering if anyone can point me in the right direction here. I'm running ArcGIS Pro 2.9.5 and am creating a tool for a Python Toolbox that will take a bunch of raster layers, and run some statistics on each, among other things.
So it will take the input rasters and statistic types (SUM, MEAN, etc.) as a Value Table (i.e., datatype='GPValueTable'). My question is how to set a default for a column in this scenario, specifically the Statistic type. In the code snippet below, setting inRasterList.values = [['', '', 'NONE']] sets the default statistic type to NONE for the first raster, but when subsequent rasters are added, the default is not set (which is obvious from the statement syntax).
# -*- coding: utf-8 -*-
import arcpy
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "ForSys Tools (Test)"
self.alias = "ForSys Tools"
# List of tool classes associated with this toolbox
self.tools = [Tool]
class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Sample Rasters"
self.description = "Sample rasters at point locations"
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
inRasterList = arcpy.Parameter(
displayName="Raster List (Stands are created from first raster)",
name="strRasters",
datatype="GPValueTable",
parameterType="Optional",
direction="Input"
inRasterList.parameterDependencies = [inRasterList.name]
inRasterList.columns = [["GPRasterLayer", "Raster Layer"], ["GPString", "Output Field Name"], ["GPString", "Statistic Type"]]
inRasterList.filters[2].type = "ValueList"
inRasterList.filters[2].list = ['NONE', 'MIN', 'MAX', 'MEAN', 'SUM']
inRasterList.values = [['', '', 'NONE']]
parameters = [inRasterList]
return parametersSo is there some code that can be added to the updateParameters function that will accomplish this? Thanks for any help!