Subset Features is designed to do that.
#Populates an existing attribute with a randomly generated value try: import operator, os, random, traceback, sys, arcpy arcpy.AddMessage("Adding random numbers to an existing attribute.") arcpy.AddMessage("Copyright 2011, Gerry Gabrisch, gerry@gabrisch.us") #Path to the feature class. fc = arcpy.GetParameterAsText(0) #The Attribute to populate... attribute = arcpy.GetParameterAsText(1) uc = arcpy.UpdateCursor(fc) for row in uc: x = random.random() row.setValue(attribute, x) uc.updateRow(row) arcpy.AddMessage("Done") except arcpy.ExecuteError: msgs = arcpy.GetMessages(2) arcpy.AddError(msgs) arcpy.AddMessage(msgs) except: tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(pymsg) arcpy.AddError(msgs) arcpy.AddMessage(pymsg + "\n") arcpy.AddMessage(msgs)
I'm guessing you're eight years beyond needing an answer to this question. But here is some more info: In ArcGIS Pro 2.8, you can use the Create Random Points tool to select a subset, using your original point feature class as the "Constraining Feature Class". The attributes are not preserved in the output as you note; however, you can join via the CID field, matching to the OID in the original data source.
Or select by location using the new feature as the intersecting feature!
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.