Thetoolbox
API
toolbox
API Reference¶
ArcGIS python toolboxes for propagator
.
This contains Classes compatible with ArcGIS python toolbox infrastructure.
- Geosyntec Consultants, 2015.
Released under the BSD 3-clause license (see LICENSE file for more info)
Written by Paul Hobson (phobson@geosyntec.com)
-
propagator.toolbox.
propagate
(subcatchments=None, id_col=None, ds_col=None, monitoring_locations=None, value_columns=None, output_path=None)¶ Propgate water quality scores upstream from the subcatchments of a watershed.
Parameters: subcatchments : str
Path to the feature class containing the subcatchments. Attribute table must contain fields for the subcatchment ID and the ID of the downstream subcatchment.
id_col, ds_col : str
Names of the fields in the
subcatchments
feature class that specifies the subcatchment ID and the ID of the downstream subcatchment, respectively.monitoring_locations : str
Path to the feature class containing the monitoring locations and water quality scores.
value_columns : list of str
List of the fields in
monitoring_locations
that contains water quality score that should be propagated.output_path : str
Path to where the the new subcatchments feature class with the propagated water quality scores should be saved.
Returns: output_path : str
Examples
>>> import propagator >>> from propagator import utils >>> with utils.WorkSpace('C:/gis/SOC.gdb'): ... propagator.propagate( ... subcatchments='subbasins', ... id_col='Catch_ID', ... ds_col='DS_ID', ... monitoring_locations='wq_data', ... value_columns=['Dry_Metals', 'Wet_Metals', 'Wet_TSS'], ... output_path='propagated_metals' ... )
-
propagator.toolbox.
accumulate
(**params)¶ Not yet implemented
-
class
propagator.toolbox.
BaseToolbox_Mixin
¶ Bases:
object
-
isLicensed
()¶ PART OF THE ESRI BLACK BOX.
Esri says:
Set whether tool is licensed to execute.So I just make this always true b/c it’s an open source project with a BSD license – (c) Geosyntec Consultants – so who cares?
-
updateMessages
(parameters)¶ PART OF THE ESRI BLACK BOX.
Esri says:
Modify the messages created by internal validation for each parameter of the tool. This method is called after internal validation.But I have no idea when or how internal validation is called so that’s pretty useless information.
-
updateParameters
(parameters)¶ PART OF THE ESRI BLACK BOX.
Automatically called when any parameter is updated in the GUI.
The general flow is like this:
- User interacts with GUI, filling out some input element
self.getParameterInfo
is called- Parameteter are fed to this method as a list
I used to set the parameter dependecies in here, but that didn’t work. So now this does nothing and dependecies are set when the parameters (as class properties) are created (i.e., called for the first time).
-
getParameterInfo
()¶ PART OF THE ESRI BLACK BOX
This must return a list of all of the parameter definitions.
Esri recommends that you create all of the parameters in here, and always return that list. I instead chose to create the list from the class properties I’ve defined. Accessing things with meaningful names is always better, in my opinion.
-
execute
(parameters, messages)¶ PART OF THE ESRI BLACK BOX
This method is called when the tool is actually executed. It gets passed magics lists of parameters and messages that no one can actually see.
Due to this mysterious nature, I do the following:
- turn all of the elements of the list into a dictionary so that we can access them in a meaningful way. This means, instead of doing something like
dem = parameters[0].valueAsText zones = parameters[1].valueAsText # yada yada nth_param = parameters[n].valueAsText
for EVERY. SINGLE. PARAMETER, we can instead do something like:
params = self._get_parameter_values(parameters, multivals=['elevation']) dem = params['dem'] zones = params['zones']. # yada
This is much cleaner, in my opinion, and we don’t have to magically know where in the list of parameters e.g., the DEM is found. Take note, Esri.
- call
self.analyze()
.
-
workspace
¶ The directory or geodatabase in which the analysis will occur.
-
subcatchments
¶ The subcatchments polygons to be used in the analysis.
-
ID_column
¶ Name of the field in the subcatchments layer that uniquely identifies each subcatchment.
-
downstream_ID_column
¶ Name of the field in the subcatchments layer that specifies the downstream subcatchment.
-
output_layer
¶ Where the propagated/accumulated data will be saved.
-
add_output_to_map
¶ If True, the output layer is added to the current map
-
-
class
propagator.toolbox.
Propagator
¶ Bases:
propagator.toolbox.BaseToolbox_Mixin
ArcGIS Python toolbox to propagate water quality metrics upstream through subcatchments in a watershed.
Parameters: None See also
-
monitoring_locations
¶ The monitoring location points whose data will be propagated to the subcatchments.
-
value_columns
¶ The names of the fields to be propagated into upstream subcatchments.
-
analyze
(**params)¶ Propagates water quality scores from monitoring locations to upstream subcatchments. Calls directly to
propagate()
.
-
-
class
propagator.toolbox.
Accumulator
¶ Bases:
propagator.toolbox.BaseToolbox_Mixin
ArcGIS Python toolbox to accumulate subcatchments attributes and water quality parameters downstream through a stream.
Parameters: None See also
-
direction
= 'downstream'¶
-
streams
¶ The streams who will accumulate attributes from subcatchments.
-
value_columns
¶
-
static
analyze
(**params)¶ Accumulates subcatchments properties from upstream subcatchments into stream. Calls directly to
accumulate()
.
-