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.

How do I get the ArcGIS 9.3 geoprocessor to copy all of the fields of a feature class?

Here is a description of what I'm trying to do:

I am modifying an existing script created by a developer not on the program anymore. The script's purpose is to extract a given feature set into a zipped .gdb. Therefore, the script takes a feature set as input. In the FeatureSet that I am attempting to export (which is a feature set representing major lakes), the fields are DEPTH, NAME, OBJECTID, Shape_Area, Shape_Length, SQKM, SQMI, and SURF_ELEV. The .gdb resulting from this script, however, only contains OBJECTID, Shape (where'd that come from??), Shape_Length, and Shape_Area.

I am exporting the feature set via

gp.CopyFeatures(featureSet, scratchGdb + os.path.sep + lyrName)

The .gdb is successfully created, but only some fields are there! Why am I losing some of the fields in this feature class when exporting it to a .gdb???

Through using Komodo IDE, I was able to remote debug the script, and I saw that the input feature set only had the four fields that ended up in the exported .gdb. Why the heck is this? Does this have to do with setting a schema for the feature set?

Please help!

Thanks!

share|improve this question
1  
What is the purpose of creating a feature class before copying your original over to the GDB? CopyFeatures should create a new FC with all of its fields. –  Nathanus Jan 16 '12 at 21:17
1  
Are all fields visible in the layer you are using as the template to CreateFeatureClass? Maybe only the visible ones are going across. –  PolyGeo Jan 16 '12 at 23:18
    
@Nathanus, PolyGeo, and Chad: I am modifying an existing script created by a developer not on the program anymore. I do not know why that call to gp.CreateFeatureClass was there. As per your recommendations, I removed the gp.CreateFeatureClass line and left the gp.CopyFeatures line there. As you said, the .gdb was created. However the same issue is occurring. In the FeatureSet that I am using, the fields in a featureSet which contains major lakes are DEPTH, NAME, OBJECTID, Shape_Area, Shape_Length, SQKM, SQMI, and SURF_ELEV. The .gdb resulting from this sc –  user5521 Jan 17 '12 at 23:04
    
If you're TrueLifeCoder, which you seem to be, you should place this answer as an edit to your original question. Although if you changed accounts, I guess you'd have to have a Moderator change ownership if that's even possible. –  Nathanus Jan 17 '12 at 23:18
    
Nathanus is right, Alex. The problem is that your account and that of TrueLifeCoder are completely different: they use different identifiers. We can merge the two accounts if both of them make the request to do so. –  whuber Jan 17 '12 at 23:39

1 Answer 1

You shouldn't have to create the featureclass first using gp.CreateFeatureClass. CopyFeatures should create it for you. Try that and see what you get. And it sounds like you are using a layer selection, otherwise all of your features will get copied and not just your selected ones.

share|improve this answer
    
I tried that and got the result mentioned in the edited question. Please let me know why this could be. Thanks! –  TrueLifeCoder Jan 18 '12 at 18:38

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.