AnsweredAssumed Answered

FieldInfo fails when using SpatialJoin

Question asked by kimo on Jan 24, 2013
Latest reply on Jan 27, 2013 by kimo
I am trying to do a point-in-polygon overlay using SpatialJoin and at the same time suppress most of the fields and rename the ones I want to keep.

Theoretically all possible with a layer and a fieldInfo object.
However if I attempt to rename the field in the fieldInfo object, then Spatial Join gets confused.

The field is added, but the contents are empty.
If I change back to leave the alias the same as the field name it works correctly.

Is there a way around this? Do I have to write out an intermediate featureclass first?
 import arcpy from datetime import datetime import sys try:     ws = sys.argv[1] except:     ws = "path/mydb.gdb" arcpy.env.workspace = ws arcpy.env.overwriteOutput = True # make a view to suppress unwanted fields hidemap = [] lstFields = arcpy.ListFields("locality") dKeep = {'SUBURB_ID':'SUBURB_ID','SUBURB_4TH':'SUBURB','MAJOR_NAME':'CITY'} # Create a fieldinfo object fieldinfo = arcpy.FieldInfo() # Iterate through the fields and set them to fieldinfo for field in lstFields:     if in dKeep.keys() :         fieldinfo.addField(, dKeep[], "VISIBLE", "")     else:         fieldinfo.addField(,, "HIDDEN", "")"locality","locality_lay",field_info=fieldinfo) arcpy.SpatialJoin_analysis("refAdd2",                            "locality_lay",                            "refAdd3",                            "JOIN_ONE_TO_ONE",                            "KEEP_ALL") print "big fail"                          

Version 10.1 SP1