2

I am trying to create a layer from a feature class that exists within a feature dataset within a geodatabase. Using the interface, I can simply add data and click through the gdb and the feature data set, so I know the data does exist.

When I try to do the same in ArcPy, using this code

import arcpy
arcpy.env.workspace = r"C:\Users\mquentel\Dropbox\PLSS\GIS"
arcpy.MakeFeatureLayer_management(r"\CadNSDI\AL_CadNSDI_V2.gdb.9-1-16\AL_CadNSDI_V2.gdb\CadastralReference\PLSSFirstDivision", "Sections")

it gives out error 000732 data set does not exist or is not supported

Following Vince's advice I have run the same code without the feature data set in the path (see below) but it returns the same error.

arcpy.MakeFeatureLayer_management(r"\CadNSDI\AL_CadNSDI_V2.gdb.9-1-16\AL_CadNSDI_V2.gdb\PLSSFirstDivision", "Sections")

Using the advice from Constructing file path within Python for Feature Class within Feature Dataset?, I checked whether the file existed:

print(arcpy.Exists(r"C:/.../AL_CadNSDI_V2.gdb/CadastralReference/PLSSFirstDivision"))

where CadastralReference is the name of the feature dataset and PLSSFirstDivision is the name of the feature class as specified when checking the layer's properties and it gives out False (i.e. the data does not exist).

Here is a screenshot of the catalog as well as of the layer's properties I get if I add the data manually through the interface.

enter image description here

I have tried backslashes (with r), forwardslashes and also joining paths using os.join and the names of the feature dataset and class.

Where am I making the mistake?

7
  • 1
    A shapefile cannot exist within a geodatabase, much less within a feature dataset. Please edit the question to show a screnshot from the Catalog window of the data organization, and include a snippet the arcpy code you have written that generates the error.
    – Vince
    Commented Nov 16, 2016 at 11:32
  • You seem to be using "shapefile" as a generic term for a data source (use "feature class" or "table" instead). You also appear to be using feature datasets as a folder for organizing data (this is a violation of best practice, and will slow and complexify data access needlessly). Since feature datasets are not actually folders, the feature classes within them exist at the top level of the file geodatabase as tables, so removing the FDS from the path may be all that is necessary.
    – Vince
    Commented Nov 16, 2016 at 12:15
  • Thank you for your patience, Vince. As you can see, I am not too familiar with the appropriate terms but I hope I could correct all wrong doing. Also, the data came organized in feature datasets when I downloaded it from the original source. Unfortunately, leaving out the FDS still produces the same error. Any other ideas? Thank you for all your help, and again, patience. Commented Nov 16, 2016 at 12:26
  • Try removing \ sign in front of path: arcpy.MakeFeatureLayer_management(r"\CadNSDI\AL_....) to arcpy.MakeFeatureLayer_management(r"CadNSDI\AL_....)
    – Bera
    Commented Nov 16, 2016 at 12:51
  • 4
    BTW you should probably avoid naming folders .gdb
    – Bera
    Commented Nov 16, 2016 at 13:00

1 Answer 1

2

Avoid naming folders .gdb

When i run this code i get a feature Count (two features in land_lyr):

import arcpy
arcpy.env.workspace = r'C:\TEST.gdb'
arcpy.MakeFeatureLayer_management(in_features=r'testtop\land', out_layer='land_lyr')
print arcpy.GetCount_management('land_lyr')

enter image description here

But with a folder containing .gdb i folder name it will fail:

import arcpy
arcpy.env.workspace = r'C:\ERROR.gdb.1234\TEST.gdb'
arcpy.MakeFeatureLayer_management(in_features=r'testtop\land', out_layer='land_lyr')
print arcpy.GetCount_management('land_lyr')

> arcgisscripting.ExecuteError: Failed to execute. Parameters are not
> valid. ERROR 000732: Input Features: Dataset testtop\land does not
> exist or is not supported Failed to execute (MakeFeatureLayer

enter image description here

A good way to get correct path to a feature class is to navigate to it in ArcCatalog (or in catalog inside ArcMap as shown below) and use Location window:

enter image description here

2
  • Thank you Dan Jurgella and BERA. I changed the folder name manually, removing the .gdb and now it works. Beautiful, thank you! Commented Nov 16, 2016 at 14:26
  • Thank you for the notice. I think, I have accepted the answer now. (If not, please say so. I am new to the system. Thank you all.) Commented Nov 16, 2016 at 16:54

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.