I have point layer, counties border area layer and I want to pick different number of points within different areas (counties) but from existing point layer - e.g. county A -> 10, county B -> 6, etc.
I'm wondering if code delivered by @Emil Brundage in Randomly subsetting X% of selected points using ArcPy? could be changed to use field values and area borders (like in Create Random Points tool) instead of one indicated count value to select random points from whole point layer. Because this code does only this.
Did I describe it clearly now?
def SelectRandomByCount (layer, count):
import random
layerCount = int (arcpy.GetCount_management (layer).getOutput (0))
if layerCount < count:
print "input count is greater than layer count"
return
oids = [oid for oid, in arcpy.da.SearchCursor (layer, "OID@")]
oidFldName = arcpy.Describe (layer).OIDFieldName
path = arcpy.Describe (layer).path
delimOidFld = arcpy.AddFieldDelimiters (path, oidFldName)
randOids = random.sample (oids, count)
oidsStr = ", ".join (map (str, randOids))
sql = "{0} IN ({1})".format (delimOidFld, oidsStr)
arcpy.SelectLayerByAttribute_management (layer, "", sql)