Select to view content in your preferred language

In ArcGIS Pro model builder, how do I pass number output of Get Field Value to an expression in Select Layer by Attribute?

72
1
yesterday
MahreenKohkar
New Contributor

I am trying to automate the selection of polygons from a feature layer based on polygon area. Specifically, I need to select only thoes polygons whose area is greater than or equal to the median area of all polygons in the layer.

Because this workflow will be repeated with different datasets, the median will change each time and cannot be entered manually.

The screenshot below shows my current ModelBuilder flow. The Value box shows the median area for one of the several input polygon layers, which I want to pass into the Select Layer By Attribute tool.

What I’m unsure about is whether I can pass this median value directly into the tool’s expression parameter, or if I need an intermediate step to construct a full SQL expression string (e.g. "AREA_FIELD" >= median) that can then be passed into the Select Layer By Attribute tool.

oLfTeiA4.png

0 Kudos
1 Reply
BobBooth1
Esri Regular Contributor

1. I would suggest renaming the variable to something like "MedValue".

2. Add a precondition that the variable must exist before the Select by Attribute tool runs.

3. Switch on the SQL toggle on the Select Layer by Attribute tool to enable you to edit the expression by typing rather than by drop-down menus.

4. In the editor, add the variable name wrapped in % signs to the expression. The expression would be something like:

Shape__Area > %MedVal%

BobBooth1_0-1767033426157.png

That worked for me.