Select to view content in your preferred language

Supplying a list of shapefiles to be intersected

182
4
Jump to solution
4 weeks ago
Labels (3)
CamKenny2
New Contributor III

I have quite a few folders that contain up to 34 shapefiles that I need to supply to the intersect tool.

Is there a way in model builder to get the list of shapefiles in a folder and supply that list to the intersect tool as each folder can various amounts of shapefiles and names.  They are all polygons and I can supply the workspace as a parameter, just not sure how to create a list and pass that on to the intersect tool.

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
CamKenny2
New Contributor III

I ended up finding a python script that did mostly what I wanted to do and with a little tweaking, managed to get it to work.

View solution in original post

4 Replies
BobBooth1
Esri Contributor

If you go with Python, you can use List Feature Classes:

https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listfeatureclasses.htm

That works for a given workspace (folder, in this case), so you would need to iterate over the folders and run it on each and collect the results.

Here is a tutorial that shows how to use List Feature Classes:

https://learn.arcgis.com/en/projects/automate-a-geoprocessing-workflow-with-python/

If you stick to ModelBuilder maybe you can do something with Iterate Workspaces:

https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/iterate-workspaces.htm

 

 

0 Kudos
CamKenny2
New Contributor III

Unfortunately, I'm not a python kind of guy so it's modelbuilder for me.

The iterate workspace doesn't seem to work for me so I tried the iterate feature class.  The iteration works and I can pass that to the intersect tool, but it doesn't add them as additional datasets to intersect.  It iterates through each shapefile and intersects it with itself and results in an empty output.

CamKenny2_0-1715801601174.png

 

0 Kudos
BobBooth1
Esri Contributor

May be able to do it in ModelBuilder with a variable of type Multivalue. You could populate it with a list of feature classes using the Calculate Value model tool and a little bit of Python in the code block. Once populated you could pass it to the Intersect tool as the input feature class list.

0 Kudos
CamKenny2
New Contributor III

I ended up finding a python script that did mostly what I wanted to do and with a little tweaking, managed to get it to work.