Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 'DEFINING PROJECTION'

    print 'FEATURECLASS = ' + str(featureclass)
    print 'PROJECTION = ' + str(prjfile)
    time.sleep(1)
    try:


        gp.DefineProjection_management(featureclass, prjfile)

    except:
        traceback.print_exc()
        time.sleep(2)

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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)

share|improve this answer
    
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
2  
@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

 
discard

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.