I am importing multiple shapefiles into a filegdb in ArcGIS 10, and using the following code to define the projection of the feature once imported, to the .prj of the original .shp file.

Here is my code:

for spatial in SpatialRefList:
    del gp
    import arcpy as gp

    print 'FEATURECLASS = ' + str(featureclass)
    print 'PROJECTION = ' + str(prjfile)

        gp.DefineProjection_management(featureclass, prjfile)


However the code is throwing up error 000289 - failed to alter spatial reference.


GDBs are just like a file tree structure. Feature Datasets can only contain feature classes in one spatial reference.
However there is another object called a feature dataset that will allow you to seperate and assign different references per feature dataset.
esri help feature dataset
esri hellp creating feature dataset (code)

  • thanks for the link, you cleared up my confusion as to why each featureclass didn't just act in the same way as a shapefile. I am in fact using feature datasets (one per country) in my file gdb structure - however I was trying to change each featureclass's sp ref individually. Cheers Again I'll amend my code to set each featuredatasets prj! – Alex Oulton Feb 7 '12 at 13:55
  • 3
    @brad-nesom, feature classes within a gdb that are not within a feature dataset can have any spatial reference. Alex was using feature datasets, thus the error message. – mkennedy Feb 7 '12 at 16: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.