I have a nationwide featureclass called bakeries. In the bakeries FC, there is a field called "State" and the field is populated with state abbreviations(AL,NJ,CT,etc). I have another feature class called United States, and that FC also has a field called "State" but it is populated with full state name.
The bakeries dataset has some poorly geocodeded points that say that they are in a state(Alabama for example) but the location of the points falls outside the state boundary, sometimes very far away.
Here is a snippet of what I have so far, you'll see that the code works but returns me everything that falls outside of the state versus the state specific data.
My goal is to identify points that say they are within a state, but in actuality, fall outside the boundary.
for row in state_rows:
arcpy.AddMessage(str(new_name + "=" + "'" + row.getValue("STATE") + "'"))
sqlExp = new_name + "=" + "'" + row.getValue("STATE") + "'" #making SQL Statement
States2FL = arcpy.MakeFeatureLayer_management(States, outworkspace + "\\" + row.getValue("STATE")+ "_FL_FL",sqlExp) #Making Feature Layer of States.shp
FC2FL = arcpy.MakeFeatureLayer_management(fc.CatalogPath,outworkspace + "\\" + row.getValue("STATE") + "_FC_FL") #Making Feature Layer of FC
arcpy.SelectLayerByLocation_management(FC2FL,"",States2FL,"","NEW_SELECTION")#selecting all data inside respective selected state
arcpy.SelectLayerByLocation_management(FC2FL,"","","","SWITCH_SELECTION") #switch selection
record_countAF = int(arcpy.GetCount_management(FC2FL).getOutput(0)) #Get After Record count
percent = (float(record_countAF)/float(record_countb4)) * 100.00 #calc percent here