Skip to content

Instantly share code, notes, and snippets.

@scw
Created April 26, 2013 22:16
Show Gist options
  • Save scw/5470823 to your computer and use it in GitHub Desktop.
Save scw/5470823 to your computer and use it in GitHub Desktop.
BTM updateParameters example
def updateParameters(self, parameters):
validator = getattr(self, 'ToolValidator', None)
# parameter names
cols = ['bathy', 'inner', 'outer', 'scale_factor', 'output']
outer_radius = parameters[cols.index('outer')].valueAsText
bathy = parameters[cols.index('bathy')].valueAsText
if outer_radius is not None and bathy is not None:
raster_desc = arcpy.Describe(bathy)
# get the cellsize of the input raster; assume same in X & Y
cellsize = raster_desc.meanCellHeight
# calculate our 'scale factor':
scale_factor = math.ceil(float(cellsize) * int(outer_radius) - 0.5)
# try modifying our scale factor
parameters[cols.index('scale_factor')].value = scale_factor
if validator:
return validator(parameters).updateParameters()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment