2

I'm working on a project where I'm pulling some data out of SDE and putting it into a file geodatabase for a group of people to look at with a custom map. I'm writing a script using the featureclasstofeatureclass function to pull out the features. Pretty basic stuff, however when trying to run the script I'm getting the " does not exist or is not supported" error.

After checking for all the basic errors the only thing I can figure is that the script is failing because in our main SDE connection, every feature has a corresponding table with the exact same name. I tried running the script on my edit version for the same feature, where there aren't any same-named tables, and it ran fine. All I changed was the SDE path and it worked.

So is the script failing because of these duplicate names? Or is there some other possible explanation? If this is the issue can I use the describe function to get the script to select just the FC and not the table?

My question: What code or function do I need to use to check for tables or select only features. Right now in the code I'm just copying features because I'm not sure what I need to do next. I know its probably something to do with Describe or listfeatureclasses I'm just not familiar enough with these functions to know how to implement them. Thanks.

Code snippet:

#############################

#### Update Map Data Script

#############################

#### Imports:

import arcpy


#############################

#### Local variables:



warehouse = "C:\\Users\\aaronmanuel\\AppData\\Roaming\\ESRI\\Desktop10.0\\ArcCatalog\\Warehouse.sde"
meters = "\\coagiswarehouse.coagis.coa_water_meter"
MapData = "G:\\WATERMNT\\AaronManuel\\MapData\\MapData.gdb"
MapData_old = "G:\\WATERMNT\\AaronManuel\\MapData\\MapData_old.gdb"


############################

### GDB Management: Create Backup GDB and create new one

try:

    if arcpy.Exists(MapData_old):
        arcpy.Delete_management(MapData_old)
        print( "Old GDB deleted..." '\n')

    if arcpy.Exists(MapData):
        arcpy.Rename_management(MapData,"MapData_old.gdb")
        print( "Renamed MapData GDB..." '\n')

    arcpy.CreateFileGDB_management("G:\\WATERMNT\\AaronManuel\\MapData", "MapData.gdb")
    print( "Created New GDB..." '\n' '\n')

except:
    print arcpy.GetMessages(2)



#### Processes: Export features from SDE



# Meters Export
arcpy.FeatureClassToFeatureClass_conversion(warehouse + meters, MapData, "meters_test")
  • 2
    Try arcpy.Exists resources.arcgis.com/en/help/main/10.2/index.html#//… before attempting to write a feature class. If you are using arcpy.ListFeatureClasses then you shouldn't get tables, however on the describe object you shouldn't have shapeFieldName - perhaps the Crash 'n burn approach may help here. Can you post some code around the failing line just in case there's an obvious error there? – Michael Stimson Nov 10 '14 at 21:32
  • 3
    every feature has a corresponding table with the exact same name definitely sounds suspicious. If you try to create this manually in a file geodatabase you get an error message, hinting that it's not supported/desirable – Stephen Lead Nov 10 '14 at 22:53
  • 1
    It's hard to answer an ArcPy/Python question that does not include a code snippet to illustrate your precise procedure, and where you are stuck with it. – PolyGeo Nov 10 '14 at 23:15
  • I'll add the code in when I get to work tomorrow. Stephen, I agree that it is weird, however since I'm just a GIS tech in a department and not actually working for the GIS department, I'm just trying to work around what they have setup. – Aaron M Nov 11 '14 at 0:34
  • I don't see where in this code you are checking for tables. You are just creating a new file geodatabase and then copying a featureclass to it. You should probably receive the errors and look at them in details. – Devdatta Tengshe Nov 11 '14 at 13:23
0

As you said you could either do something with Describe or with ListFeatureclasses.

Describe option to check if the referenced path is a table or not, based on the fact that every feature class has an attribute featureType, whereas tables don't:

d = arcpy.Describe(warehouse + meters)
if hasattr(d, 'featureType'):
    # feature class
    your_export_function(warehouse + meters)
else:
    # table
    pass

ListFeatureClasses option, using the name of your wanted feature class as a wildcard.

arcpy.env.workspace = waterhouse
lf = arcpy.ListFeatureClasses()
for meters in lf:
    arcpy.FeatureClassToFeatureClass_conversion(warehouse + meters, MapData, meters + "_export")

Although, just like the other commenters, I find it strange that several datasets with identical names can exist in the same space...


edit: updated the listfeatureclasses option, note that for every feature class found in warehouse, this creates a feature class with the same name plus the suffix "_export" in MapData.

  • Thanks Menno, appreciate the input. My issue though is that I'm looking to export about 20 or so features, so I am trying to figure how I could pass a list to Describe or ListFeatureClasses. Sorry that my code makes it look otherwise, I just hadn't started to put in the additional features since I couldn't even get the first one to export when I tested it. So could I put your describe example in a for loop? – Aaron M Nov 11 '14 at 16:38
0

Based on the answers and comments here is a snippet of what I ended up doing:

dataList = [ ###list of variables defined above### ]

env.workspace = warehouse

warehouseList = arcpy.ListFeatureClasses("*", "", "")

print "Created Lists \n"


print "Loop through warehouse List.... \n"

try:

    for warehouseList in dataList:
        arcpy.CopyFeatures_management(warehouseList, MapData + "\\" + warehouseList) 

except:
    print arcpy.GetMessages(2)

Maybe there is a cleaner way to do this but its working for me so far.

  • That's about what I was going to suggest, the only thing I don't get in this is the for warehouseList in dataList. Have a look at my updated answer. – Menno Nov 12 '14 at 9:28

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.