6

I've got some Sea Level Rise data from NOAA (https://coast.noaa.gov/slrdata/) stored in 66 different geodatabases. Each geodatabase represents a state or district and contains a set of feature classes of sea level rise at different depth (0 feet, 1 feet,...). As is shown in these pictures:

enter image description here

enter image description here

My aim is to merge all the features that have the same water depth, for example, 0 feet, to a single feature class to create a sea level rise map of the US at different water depths. So I used Arcpy to find polygon feature classes that end with "slr_0ft" through these geodatabases. And then merge the results to one single feature class. Here's the code I used:

import arcpy, os
workspace = "G:\DirectStudy\SLR\gdb" #My workspace that contains 66 GDBs
search = "slr_0ft"
feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,
                                                  datatype="FeatureClass",
                                                  type="ANY"):
    for fname in filenames:
        # search for string in string to eliminate the need for exact filenames
        if search.upper() in fname.upper():
            feature_classes.append(os.path.join(dirpath, fname))
    for fc in feature_classes:
         print fc

arcpy.Merge_management(feature_classes, "G:\DirectStudy\SLR\Merge_0ft")  
print "Done!!"

The code was successful in printing paths and filenames (see below). But the output file from the merge function is an empty shapefile. I checked it with ArcMap and found it contains no polygon. Also, the script didn't give me any kind of error or warning. I guess the mistake should be in the arcpy.Merge_management() function. How can I fix my script? enter image description here

I'm not a native speaker so I tried best to explain my question clearly.

4
  • 1
    Could you please report the results from print(feature_classes)?
    – Aaron
    Aug 9, 2020 at 7:42
  • @Aaron only the beginning part of it:[u'G:\\DirectStudy\\SLR\\gdb\\ALFL_MOB_TLH_slr_final_dist.gdb\\ALFL_MOB_TLH1_slr_0ft', u'G:\\DirectStudy\\SLR\\gdb\\ALFL_MOB_TLH_slr_final_dist.gdb\\ALFL_MOB_TLH2_slr_0ft', u'G:\\DirectStudy\\SLR\\gdb\\ALFL_MOB_TLH_slr_final_dist.gdb\\ALFL_MOB_TLH3_slr_0ft', ... It managed to find the paths and files names I want but failed in merge all this feature classes together. It seems the code can only process merge in just 3 or 4 GDBs. Aug 9, 2020 at 16:04
  • 2
    It looks like you need to define a valid output featureclass in the merge tool. It appears as if you are defining an output directory rather than an output featureclass.
    – Aaron
    Aug 9, 2020 at 18:06
  • try arcpy.Merge_management(feature_classes, "G:\DirectStudy\SLR\Merge_0ft") code inside bit to align two for loop and try. Just wild guess..! Sep 17, 2021 at 10:05

1 Answer 1

1

As commented by @Aaron:

It looks like you need to define a valid output featureclass in the merge tool. It appears as if you are defining an output directory rather than an output featureclass.

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.