Created
April 26, 2013 22:16
-
-
Save scw/5470823 to your computer and use it in GitHub Desktop.
BTM updateParameters example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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