Creating empty feature class in file geodatabase based on schema of ArcSDE feature class?

Short of being able to figure out why you cannot export an XML schema from SDE, there is a quick and dirty method you might try. This will depend on if you have enough space and privileges.

  1. Create an empty file geodatabase.
  2. Use the copy featureclass tool with the batch option to copy all 150 featureclasses from the SDE geodatabase to your empty file geodatabase.
  3. Set up a python script to cycle through all the featureclasses and run the delete features tool on each of them.

Assuming this works, it should leave you with a file geodatabase that contains all of the empty featureclasses from SDE with all the attribute fields and even the domains and relationship classes if they were defined.

It is definitely clunky, but I've also run across a schema that would not export to an xml workspace due to errors in the schema.

As for your other question, you might check out this help topic on working with geometries It should at least get you on the right track. It may also help to post that as a separate question, or search to see if it has already been asked.

Good luck!


Just use the CreateFeatureClass tool, passing the original feature class as the template argument. Grab the shape type from the Describe object of the input feature class.

Unlike the other answer, this won't copy a bunch of unnecessary records only to delete them right away.

import arcpy
arcpy.env.workspace= 'MyGDB.gdb'
fcs = arcpy.ListFeatureClasses()
output = "OutGDB.gdb"
for fc in fcs:
    geom = arcpy.Describe(fc).shapeType
    arcpy.CreateFeatureclass_management(output, fc, geom, fc, spatial_reference=fc)

UPDATE:

If you need to preserve domains/subtypes, then run Select_analysis using a generic where clause that will capture none of the records, like OBJECTID < 0:

import os, arcpy
arcpy.env.workspace= 'MyGDB.gdb'
fcs = arcpy.ListFeatureClasses()
output = "OutGDB.gdb"
wc = 'OBJECTID < 0'
for fc in fcs:
    fc_out = os.path.join(output, fc)
    arcpy.Select_analysis(fc, fc_out, wc)

This is far more efficient than copying all the records and then deleting them. I've yet to find an approach that will preserve editor tracking.