4

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.

7
  • 3
    Your question is well explained and it is always good to see code, output, screenshots. You state your output should be a shapefile but the output file name is for a coverage. Try setting your output file name to be "G:\DirectStudy\SLR\Merge_0ft.shp"?
    – Hornbydd
    Aug 8 '20 at 12:12
  • Try outputting to a file geodatabase. Maybe the shape gets to big, or to many fields etc..
    – BERA
    Aug 8 '20 at 13:39
  • @BEAR@Hornbydd Thanks for your advice. I tried to apply my code on a smaller dataset, like, 4 geodatabases from the total. And it worked fine no matter outputting as a shapefile or geodatabase. The reason might be the number of features is too large. Processing could take dozens of hours. I'm trying to divide my GDBs into different groups and run the code again. Aug 8 '20 at 17:02
  • 1
    Could you please report the results from print(feature_classes)?
    – Aaron
    Aug 9 '20 at 7:42
  • 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 '20 at 18:06
0

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, privacy policy and cookie policy

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