0

I have over 3000 folders, each folders have a geodatabase and each geodatabase consist of a layer name called "lot".

I want to merge the all the "lot" layers into one layer shapefile, my gis knowledge is very limited and would like to ask some insights or tools i can use in this situation? I am thinking of these tools, and thinking how to plug each tool inside modelbuilder :

Iterate Feature classes (find the name of "lot")?,Parse path,Rename

2
  • This would be much easier in python using arcpy.da.Walk resources.arcgis.com/en/help/main/10.2/index.html#//…, is python an option for you? Beware that a shapefile has a maximum file size of 2GiB for each component, it is possible to overflow a single shapefile. Perhaps merge to a new file geodatabase then try exporting to shapefile, if that fails then cut the feature class into chunks. Commented Jul 4, 2018 at 2:02
  • unfortunately i have 0 background in programming and python :/ is it possible to get it done by modelbuilder? ima try looking at python as well
    – Dixbe
    Commented Jul 4, 2018 at 2:03

1 Answer 1

2

This is probably a good place to start learning python. Here is a little script that will do what you want:

import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))

Copy and paste into notepad, save with an extension of .py and then add it to a toolbox.

If you want to be able to specify the input base folder and output shape only a few small changes are needed:

import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)

When adding this script tool it needs two parameters, the first is a folder type the second is a feature class (or shapefile) type.

6
  • It works fine! thanks alot, i did a small testing of 4 folders! however i checked one of the field in my layer used domain code value instead of domain description, is there anything i can add to the script to do that as well?
    – Dixbe
    Commented Jul 4, 2018 at 2:44
  • There are field mapping objects but that is quite involved. What is the difference between code and description? Do they have the same values? if so then it's easier to calculate field in your output from the one you don't want into the one you do want then remove the unneeded field. Commented Jul 4, 2018 at 2:51
  • thanks, the coded value is a number while the description is a text (which is what we need) i tried joining the tables and added a field and it works just fine. However may i also ask if is possible to see insert a field on which polygon in comes from which folder(all folders have its unique zone name)? (perhaps like adding a field to see which folder's lot the polygon comes from, i can use the folder name as the result) i hope that makes sense
    – Dixbe
    Commented Jul 4, 2018 at 3:03
  • It's not as easy to add a field of where the data came from, far from impossible but as a beginner with arcpy it's likely to be a bit out of your depth. As for turning a code into a description there is a tool Domain to Table resources.arcgis.com/en/help/main/10.2/index.html#//… which exports the code/description to a table which can be joined to your data and then calculate the join_table.description into your out_shapefile.description field. Commented Jul 4, 2018 at 3:07
  • do u know the possible reason for ERROR 000735 Value is required? i tried running it with other layouts, while doing the same function (just changing base folder, layer name and output name)
    – Dixbe
    Commented Jul 5, 2018 at 9:03

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.