I have a feature class table of OBJECTIDs that I would like to use to create a table of random numbers. This output table of random numbers will be used to Relate or Join back to the original feature class in order to select those records to QA/QC. I will be doing this repeatedly and would like this to be ArcGIS script tool. I need to find the minimum, maximum, and range of the OBJECTIDs and then select a random sample of only 10% (or other % if desired) of that range from which to generate the random numbers. I know the Python random.sample(range(min,max),range) will work, but I am having trouble with the coding part. Any help is greatly appreciated. My Python skills are currently C+.
#The goal of this script is to take a list of OBJECTID values from a feature class # and find the Minimum, Maximum, and Range of that list. Using that information # then create a list of random numbers between the min and the max that is # equal to 10% of the range. The output should be a table with a column # containing the random 10% values which can then be related or joined to the # source feature class to identify a 10% random sample to analyze further. #Import the arcpy and Random modules import arcpy, os, random #Overwrite if files already exists arcpy.env.overwriteOutput = True #Setting up the paramters for the ArcGIS Python Script Tool inputfc = 'L:\\Mapping-GIS\\PLN\\GIS\\Layers\\Geodatabases\\Parcels_YearBuilt\\SWFWMD_2013_q4.gdb\\Pasco' outputfc = "L:/Mapping-GIS/PLN/GIS/Projects/PSSA/PSSA_Edits.mdb/parcel_stats" #Setting up the paramters for the OBJECTID field, or similar, to be used to generate the random numbers list from statsField = "OBJECTID" #Calculate Minimum, Maximum, Range and 10% of Range of the fc's OBJECTID field #...Used to determine the numbers that will be used to calc a random list from which later #....can be used to relate to the original OBJECTIDs to select those records which to scrutinuze further in the QA/QC process arcpy.Statistics_analysis(inputfc, outputfc, [[statsField, "MIN"], [statsField, "MAX"], [statsField, "RANGE"]]) arcpy.AddField_management(outputfc, "PERCENT_10", "DOUBLE") arcpy.CalculateField_management(outputfc, "PERCENT_10", "[RANGE_OBJECTID] * 0.10") #Testing the functionality of the random number generator # Just an example of the numbers, but I need these inputs here, to come as parameters from the outputs of the Statistics table above. x = random.sample(range(100550,355150),25460)