In this article, we will learn how to generate random values on ArcGIS Pro. We have a table and we want to fill a column with some random values. We can easily do this using Calculate Field in ArcGIS Pro. Before we can start creating these random values, we need to add a new column or field to store this number. The data type could vary depending on what kind of number we want to generate.
If we want to generate an integer number, then the data type should be Short or Long. Otherwise, we need to choose Float or Double. In the following example, I am going to add a Double field called random_value. Modify your table and add the necessary field.
Now we have a new column/field called random_value that can store the data type of Double.
Next, click Calculate Field from the attribute table to open the Calculate Field window.
In the Calculate Field window, enter the following code in the Code Block:
return random.uniform(0.05, 50.0) # Replace 1.0 and 100.0 with your desired range
You can change the numbers 0.05 and 50.0 with any numbers you want. Please note that this syntax will generate the Float numbers, not integers. Don’t forget to put this syntax generate_random() in the field above the Code Block as seen in the following picture.
Press OK and you should now have the column with random numbers. You can repeat these steps as many as you like if you need to generate different numbers.