I am trying to build a script tool for my job that takes any vector feature (roads, rails, land cover, water polygons etc) and clips it to selected geocells. The geocells are one feature with a field (ID) that displays the name of each geocell. I have used the blog post here:
to allow users of the tool to be able to select one or more geocells of their choosing to perform the clip. I want the tool built this way so that essentially any boundary type polygon can be used as the clipping feature where you can select portions of the boundary polygon based on a field value.
Here is my code:
# Import libraries and set environments import os import arcpy from arcpy import env from arcpy.sa import * from arcpy.ddd import * env.overwriteOutput = True # Set the parameters InputBoundary = arcpy.GetParameterAsText(0) InputField = arcpy.GetParameterAsText(1) InputValue = arcpy.GetParameterAsText(2) selection = arcpy.SetParameter(3, InputValue) InputFeature = arcpy.GetParameterAsText(4) Output = arcpy.GetParameterAsText(5) # Perform the Clip arcpy.PairwiseClip_analysis(InputFeature, selection, Output)
As written the tool will fail and say that I am not honoring all of the parameters of the clip analysis. That has to to with having "selection" as the clip feature. If I change "selection" to be "InputBoundary" the tool will work but instead of honoring the selection of individual geocells, the tool is clipping the features to the full extent of all geocells
The GUI of my tool looks like how I want it to and lets me select individual geocells:
As described in the link above, I am trying to expand upon the example tool to create a MULTIVALUE parameter choice list from an input feature class/table automatically.
In ArcGIS Pro, that example tool's parameters and code look like this:
I have attempted to expand upon that example tool's setup like this:
I just want to be able to input a boundary polygon, select certain parts of that polygon, and use that selection to clip out portions of another feature.