POST
|
Could you clarify where and how [validation] code gets applied? No, tool validation before your main script runs (that's the idea!) - the code is edited in the script tool properties/validation tab. If you have made the jump to Python toolboxes, the tool validation class is in a separate area of your code. (I still like doing it the old way -- less work!)
... View more
05-14-2013
07:46 AM
|
0
|
0
|
530
|
POST
|
I put a [noparse] [/noparse] around your code above so it would display correctly. The tool only supports a single value raster input. Have you tried Zonal Statistics As Table? If you use that tool, you could join the twelve output tables using the Join Field tool. Hope this helps.
... View more
05-14-2013
07:39 AM
|
0
|
0
|
765
|
POST
|
Ally, Integer rasters [post=297376]don't always have the attribute table built[/post] depending on the range and number of values. This was true in 9.3 and it is still true. You may need to run the Build Raster Attribute Table tool to get one. (If there is one there already, no harm done.)
... View more
05-13-2013
09:16 PM
|
0
|
0
|
665
|
POST
|
For performance reasons, it would make more sense to tag the places with the County beforehand, you don't want to do significant geoprocessing while a user is staring at the dialog box -- a delay of even a second is a long time in that situation. Here's an example of how this would work. The code below assumes: Parameter 0 is the county polygon with fields CNAME and CCODE Parameter 1 is the place points with fields PNAME and CCODE Parameter 2 is the county name (picklist) Parameter 3 is the place name (picklist) This code is untested! For guidance, see the help article "Programming a Tool Validator Class". def updateParameters(): if self.params[0].value: # get dict of county names and codes counties = {} rows = arcpy.SearchCursor(self.params[0].value,"","","CNAME;CCODE") for row in rows: nm = row.getValue("CNAME") cd = row.getValue("CCODE") counties[nm] = cd del row, rows # set up picklist (filter) of county names cnames = counties.keys() self.param[2].filter.list = sorted(cnames) # set up picklist of place names for this county if self.params[1].value and self.params[2].value: county_code = counties[self.params[2].value] where = "CCODE = {0}".format(county_code) rows = arcpy.SearchCursor(self.params[1].value,"",where,"PNAME;CCODE") pnames = [] for row in rows: pnames.append(row.getValue("PNAME")) del row, rows pnames = sorted(set(pnames)) # uniqueize and sort self.params[3].filter.list = pnames
... View more
05-13-2013
09:09 PM
|
0
|
0
|
530
|
POST
|
We have had problems with this too -- for regular users -- here's the NIM we have logged: [#NIM066910 A script run from Task Scheduler with the setting "run whether user is logged on or not" fails to initialize ArcPy when the license is single-use. ] No workaround identified for version 10.1. At 10.0, a workaround was to have a concurrent license available for arcpy to load. Glad to hear this may be finally fixed at 10.2; it's a real show-stopper of a bug. I will definitely test it first time I get a chance.
... View more
05-13-2013
08:38 PM
|
0
|
0
|
1079
|