0

I have a GeoDatabase with a handful of shapefiles. The contents are likely to change often, so I want to build a tool that allows me to merge all the shapefiles in the GDB into one layer.

This is what I currently have: enter image description here

However, I am not expecting this to work, as it seems like it would just grab one file each iteration and 'merge' it with itself. Is there a workaround so that it grabs all files from the GDB to merge them? I am using ArcGIS Desktop 10.5.

1
  • Look at the answer by @Aaron his is the correct solution.
    – Hornbydd
    Commented Jun 6, 2019 at 15:20

1 Answer 1

1

This is an arcpy solution rather than a ModelBuilder one but I believe it is pretty straightforward. To run it you just have to open the Python console in ArcMap and paste the following lines:

import arcpy

# specify the path to your GDB
arcpy.env.workspace = 'path/name.gdb'

# get all the Feature Classes in the GDB
fcs = arcpy.ListFeatureClasses()

# run the Merge tool
arcpy.Merge_management(inputs=fcs, output='merge_result')

This will create a feature class called merge_result in your GDB.

4
  • I have a Spyder environment set up with Arcpy. Unfortunately, I get the following error when running it: ExecuteError: Failed to execute. Parameters are not valid. ERROR 000735: Input Datasets: Value is required Failed to execute (Merge). Also, when I do print(fcs) the output is 'None'. Any ideas?
    – Jared
    Commented Jun 6, 2019 at 15:14
  • It is possible that the path to your gdb is not correct. Can you show me how you declared the path? Commented Jun 6, 2019 at 15:25
  • The issue was '/' vs. '\' in declaring the path. Classic. Thanks for the help!
    – Jared
    Commented Jun 6, 2019 at 15:29
  • When declaring paths in Python make sure to use double backslash (\`) or put an r` before your string to escape special sequences such as \n or \t. Commented Jun 6, 2019 at 15:31

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