Solved! Go to Solution.
import arcpy
feature_class = "c:/Data/wells.shp"
layer = "temp_layer"
arcpy.MakeFeatureLayer_management(feature_class, layer)
# Create a describe object
desc = arcpy.Describe(layer)
# Create a fieldinfo object
field_info = desc.fieldInfo
# Get index of desired field for which to set ratio policy
# Let's say your desired field is called 'area'
fldIndex = field_info.findFieldByName("area")
# Set the policy
field_info.setSplitRule(fldIndex, "RATIO")
inFeaturesAlb = "blocks_01_alb.shp"
layer = "temp_layer"
arcpy.MakeFeatureLayer_management(inFeaturesAlb, layer)
# Create a describe object
desc = arcpy.Describe(layer)
# Create a fieldinfo object
field_info = desc.fieldInfo
# Get index of desired field for which to set ratio policy
# Let's say your desired field is called 'area'
fldIndex = field_info.findFieldByName("POP10")
# Set the policy
field_info.setSplitRule(fldIndex, "RATIO")
######################################################################
#Do the intersection
#####################################################################
intOut = "State_01_int_3.shp"
inFeatures_int = [USA_layer, layer]
arcpy.Intersect_analysis(inFeatures_int, intOut)
Hi Wayne --
Sorry to keep this going but I've had trouble making this work in a stand-alone setting. I used the code above, which seemed to work fine. However, when I proceeded the intersect the ratio split policy wasn't honored. I'm wondering if I'm missing a step to connect the policy more explicitly back to the layer that is input to the intersect. Code below.
Thanks for any thoughts,
Mike
inFeaturesAlb = "blocks_01_alb.shp" layer = "temp_layer" arcpy.MakeFeatureLayer_management(inFeaturesAlb, layer) # Create a describe object desc = arcpy.Describe(layer) # Create a fieldinfo object field_info = desc.fieldInfo # Get index of desired field for which to set ratio policy # Let's say your desired field is called 'area' fldIndex = field_info.findFieldByName("POP10") # Set the policy field_info.setSplitRule(fldIndex, "RATIO") ###################################################################### #Do the intersection ##################################################################### intOut = "State_01_int_3.shp" inFeatures_int = [USA_layer, layer] arcpy.Intersect_analysis(inFeatures_int, intOut)
import arcpy
# Local variables:
blocks_01_alb_shp = "...\\blocks_01_alb.shp"
USA_int_131111 = "USA_int_131111"
State_01_int_7_shp = "...\\State_01_int_7.shp"
blocks_01_alb_Layer1 = "blocks_01_alb_Layer1"
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(blocks_01_alb_shp, blocks_01_alb_Layer1, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;STATEFP10 STATEFP10 VISIBLE NONE;POP10 POP10 VISIBLE RATIO")
# Process: Intersect
arcpy.Intersect_analysis("blocks_01_alb_Layer1 #;USA_int_131111 #", State_01_int_7_shp, "ALL", "", "INPUT")
inFeaturesAlb = "blocks_01_alb.shp"
# Create a describe object
desc = arcpy.Describe(inFeaturesAlb)
# Create a fieldinfo object
field_info = desc.fieldInfo
# Get the field index and set ratio policy
field_info.setSplitRule(field_info.findFieldByName("POP10"), "RATIO")
layer = "temp_layer"
arcpy.MakeFeatureLayer_management(inFeaturesAlb, layer, '', '', field_info)
######################################################################
#Do the intersection
#####################################################################
intOut = "State_01_int_3.shp"
inFeatures_int = [USA_layer, layer]
arcpy.Intersect_analysis(inFeatures_int, intOut)