Hey all,
I am pretty new to Model Builder, and a question pertaining to selecting polygons based on points.
I have a large number of Layers each containing points of interest. I also have 1 layer which holds all of my polygons. I need to use the points from each layer to select the polygons and save that selection of polygons. The new layer containing the selected polygons should retain the name of the Point layer that was used to select it. and I need it to iterate through each of the point layers selecting and saving a different set of polygons.
So far I have not been able to really eve start tis project since I cant seem to find an iterator that will let me limit what point layers I want it to iterate through. The ones that look most promising seem to want me to set the entire GDB as the source, which would be fine if I didn't also have data I don't want it to iterate through.
Can anyone show me a screen shout of how I should begin to set this project up by any chance? Thanks in advance.
Solved! Go to Solution.
For example. I have a map with several point layers that include the string "Patients". I can iterate layers, with the input Wildcard of *Patient*, the layer type of "Feature Layer" and the feature type of "Point". This will go through the three layers on my map that match these criteria.
I then use select layer by location to find the polygons in my counties layer that intersect those points. I use Copy Features with an inline variable on %Name% and a suffix of _co (short for counties), to export them to new feature classes. *Note* that you will need to make sure the layers on your map have names that are permissible geodatabase feature class names - "Current Patients" doesn't work because feature class names can't have spaces, but renaming the layer "Current_Patients" solves that... you could also use the Calculate Value model tool and ValidateTableNames (https://pro.arcgis.com/en/pro-app/3.3/arcpy/functions/validatetablename.htm) to catch and sanitize any offending characters, with a tiny bit of Python. Just renaming layers is simpler.
The model:
The result:
I added the result layers to my map:
Looks like this approach should work for you.
Have a look at Iterate Layers - assuming your layers are all on your map in ArcGIS Pro, you can iterate through them and filter by feature type (point) and a wildcard (some common string you use in all the layer names you want to process).
https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/iterate-layers.htm
You'll get Name as a variable off that iterator, and you can use it with inline variable substitution to name the output selected polygon layers.
You could also use Iterate Multivalue:
https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/iterate-multivalue.htm
This would require you to populate a list/table of the names of the point layers that you want to iterate over.
Hey @BobBooth1 ,
Unfortunately I'm not sure this advances my cause as Points are not an option within the iterate layers, Is there another route I can try?
Choose "Feature Layer" - then you can choose geometry.
For example. I have a map with several point layers that include the string "Patients". I can iterate layers, with the input Wildcard of *Patient*, the layer type of "Feature Layer" and the feature type of "Point". This will go through the three layers on my map that match these criteria.
I then use select layer by location to find the polygons in my counties layer that intersect those points. I use Copy Features with an inline variable on %Name% and a suffix of _co (short for counties), to export them to new feature classes. *Note* that you will need to make sure the layers on your map have names that are permissible geodatabase feature class names - "Current Patients" doesn't work because feature class names can't have spaces, but renaming the layer "Current_Patients" solves that... you could also use the Calculate Value model tool and ValidateTableNames (https://pro.arcgis.com/en/pro-app/3.3/arcpy/functions/validatetablename.htm) to catch and sanitize any offending characters, with a tiny bit of Python. Just renaming layers is simpler.
The model:
The result:
I added the result layers to my map:
Looks like this approach should work for you.
@BobBooth1 Thanks, that helped. Second question if you have time, Since feature class to Feature class no longer exists how can I save each iterated selection as its own feature class?
You can use Copy Features.
https://pro.arcgis.com/en/pro-app/3.3/tool-reference/data-management/copy-features.htm
That's where you'd be specifying the output name built with inline variable substitution.
@BobBooth1 Thank you. Hopefully one last question. It looks like Select Layer by Location is passing the name of the polygon layer or the "Input Features" as the layer name, but I need it top pass the Point Layer or "Selecting Feature" on to the next step. How can I tell model builder to pass the Selecting feature name to the next step?
Probably worth mentioning that because Model Builder is passing the Input Features name rather than the selecting features name it is currently overwriting all previous iterations as the Input feature is the same for all iterations. If there is some other way I should be going about this, I'm all ears.
Your Iterate Layers iterator has an output parameter called Name. If you bracket it with % symbols, %Name% you can use that as a variable in output feature class names. This is called Inline Variable Substitution in ModelBuilder.
For an example like your case, see: