Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a pretty simple script which gets 2 parameters from the user:

1)Geodatabase location

2)Spatial reference

It then creates a dataset with 6 feature classes. It also adds a large amount of fields to each each feature class, and by large I mean no more than 20.

It also adds defaults to certain fields.

Could I speed up the running of the tool by organizing the code differently?

Right now I have it so it creates the dataset, then creates the first feature class and then the fields it needs and any defaults for those fields.

Could it be quicker to have it make all the features classes at once, then all the fields, then all the defaults? Or would it make no difference?

Currently, it's taking about 4 minutes to do everything.

share|improve this question
Initial thoughts: 1) Why is Spatial reference a parameter? If you have more than a couple then I think you are asking for trouble when it comes to projections, datums and transformations. If you are at 10.1 then the ListTransformations method may come in handy. But you make no mention of projecting or loading data at all -- is that part of this script or a separate process entirely? – blah238 Oct 31 '12 at 4:21
2) If you could pre-author template geodatabases exactly as you want them, you could simply copy and paste them using Copy_management, for example, which would take no more than a few seconds. – blah238 Oct 31 '12 at 4:25
3) Can you post your script? – blah238 Oct 31 '12 at 4:26
@blah238 Could not agree more - empty template GDB with feature dataset per possible spatial reference would mean copy GDB then delete feature datasets with unwanted SRs. – PolyGeo Oct 31 '12 at 5:25
Empty GDBs take up practically no space, so I was thinking more along the lines of one GDB (or XML workspace document) per spatial reference but whatever works. :) – blah238 Oct 31 '12 at 5:40
up vote 2 down vote accepted

If you have a sample Geodatabase that already has the Feature Dataset you can export the schema as an XML file. To do this, in ArcCatalog right click the feature dataset and select Export then select XML Workspace Document. Follow the wizard and save the XML file somewhere.

Now modify your script to run the Import Replica Schema tool with the XML file. This should create the Feature Dataset in your geodatabase in a matter of seconds instead of minutes.

Note, you may want to run checks in your script to ensure that the Feature Dataset doesn't already exist in the selected Geodatabase.


This tool as well as the ones that @blah238 mentions in the comment to this answer, require ArcGIS Standard or ArcGIS Advanced license.

share|improve this answer
At 10.1 you also have the Import XML Workspace Document and Export XML Workspace Document geoprocessing tools. – blah238 Oct 31 '12 at 5:21
@blah238 I was looking at the 10.0 web-help and didn't see those. Those are probably better options. I edited my post to indicate that all those tools require ArcGIS Standard as a minimum. – Fezter Oct 31 '12 at 5:39
Yes they were added with little fanfare to 10.1:… – blah238 Oct 31 '12 at 5:41

First and foremost, work with layers for better performance -- therefore, after you create the feature class, turn it into a feature layer using the MakeFeatureLayer tool...then add all your fields to that layer.

Second option, and this is perhaps the fastest way, try using a numpy array:

narray = numpy.array([],
             ('TEXTFIELD1', '|S100'),
             ('FLOATFIELD', numpy.float),
             ('TEXTFIELD2', '|S100'),
             ('TEXTFIELD3', '|S100'),
             ('TEXTFIELD4', '|S100'),
             ('TEXTFIELD5', '|S100'),
             ('TEXTFIELD6', '|S100'),
             ('TEXTFIELD7', '|S100'),
             ('TEXTFIELD8', '|S100'),
             ('TEXTFIELD9', '|S100'),
             ('TEXTFIELD10', '|S100'),

    def create_feature_classes(geodatabase, spatial_reference=4326):
        sr = arcpy.SpatialReference(spatial_reference)
        fds = arcpy.CreateFeatureDataset_management(geodatabase, "FDS", sr)
        for fc in set(['fc1', 'fc2', 'fc3', 'fc4', 'fc5', 'fc6']):
            result = arcpy.CreateFeatureclass_management(fds, fc, "POLYGON", spatial_reference=sr)
            arcpy.da.ExtendTable(result, "OID@", narray, "INTID")

Running this function took about one second per feature class.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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