9

I have a WATERBODY shapefile for each region within each province in Canada. The region subfolders also contain many other features that I do not need. I am trying to upload and merge all the WATERBODY shapefiles of Canada, without searching through each of the ~1000 subfolders. Rumour has it this is possible in the 'Load Them All' plugin for QGIS but I am using ArcMap 10.3.1.

I have no knowledge of Python coding and that seems to be the answer to similar questions from 2012 on forums. Is there an ArcMap equivalent? Is there an easier way than learning Python coding for this one step?

5
  • 2
    Do you have any experience with the ModelBuilder in ArcGIS? You can simply iterate the folders and grab the files, assuming they have standardized names. Are the shapefiles you want to merge all named something like "WATERBODY.shp"?
    – Radar
    Commented Feb 4, 2016 at 21:48
  • I do not have experience with modelbuilder, but I can give it a try. Each shapefile has WATERBODY within the file name but has a bunch of numbers and letters for the region code.
    – J Brooks
    Commented Feb 4, 2016 at 22:05
  • 1
    If you're interested in learning Python, this would be a great place to start. Just sayin' ;) Commented Feb 4, 2016 at 22:08
  • As Nick O wrote, use the "Iterate Datasets" tool. Create a new model, and then in the the main menu go to "Insert / Iterators / Datasets". Note that iterators are ModelBuilder only tools, so you won't find a tool like this in the default ArcToolbox, you must insert it from the main menu of an opened model.
    – Marco_B
    Commented Feb 4, 2016 at 22:13
  • How did you go with this? If either of the answers provided fit your needs, you can select one as 'the' answer, otherwise perhaps you can add an answer explaining how you achieved your objective.
    – Adam
    Commented Mar 6, 2017 at 23:17

2 Answers 2

9

The good news is you can achieve this without 'learning' Python coding. The bad news is, you still need to use Python code!

Open a fresh instance of ArcMap, go to the Geoprocessing menu and select Python. This will open the Python window. Since there are so many datasets to be added (and therefore drawn), I recommend pausing the data view before proceeding.

Type the following code into the Python window. Make sure you indent your code in the same way (use four spaces for a single indent, 8 for a double etc). You will need to replace the path C:/DATA with the path of your base folder, making sure you use forward slashes "/" in the path rather than backslashes (don't ask or you will be learning coding!). You will need to replace the text WATERBODY with some other characters which occur in the filename of every waterbody dataset (do this in CAPTIALS). Once you've altered the path, press Enter

import os

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

workspace = "C:/DATA"    #place the path to your data inside the quote marks, remembering to use forward slashes
feature_classes = []

walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="Polygon")

for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        feature_classes.append(os.path.join(dirpath, filename))

for dataset in feature_classes:
    dataset = dataset.upper()
    if "WATERBODY" in dataset:
        add_layer = arcpy.mapping.Layer(dataset)
        arcpy.mapping.AddLayer(df, add_layer)

Your computer might have to think about thinks for a few seconds/minutes. Once it has finished, you should have all the datasets which are located within that folder and sub-folders, shown in the Table of Contents. Now it's up to you what you want to do with them!

4

This works for shapefiles only!

In windows Explorer use wildcard WATER*.shp or similar to locate them. Select them all in search result, drag and drop to your mxd

2
  • 2
    The real question now is, what will go "Not Responding" first, Windows Explorer, or ArcMap?
    – Radar
    Commented Feb 4, 2016 at 22:55
  • One of them will die:) I'd use merge tool, it might handle
    – FelixIP
    Commented Feb 4, 2016 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.