HOW TO

Generate a random number within a range for labels in ArcGIS Pro

Last Published: April 26, 2024

Summary

In ArcGIS Pro, a random number within a range can be generated using Arcade expressions to label each feature on the map. This allows for a better visualization of the random classification on a map when performing predictive analysis.

This article provides an example and instructions using Arcade expressions to generate a random number within a range for labels in ArcGIS Pro.In this article's example, the TampaBuildings layer contains polygon features of buildings in Tampa.

The image below shows a map in ArcGIS Pro without random numbers on the polygon features.

The polygon features without random numbers on the map

Procedure

  1. Start ArcGIS Pro and open the project.
  2. In the Contents pane, right-click the feature class and click Labeling Properties... to open the Label Class pane.
The Contents pane in ArcGIS Pro
  1. In the Label Class pane, click the Label expression The Label expression icon button and configure the following parameters.
    1. For Language, select Arcade.
    2. Specify the following script in the Expression section.
Round(Random() * (<valueDigit1> - <valueDigit2>) + <valueDigit2> , <numberOfDecimal>)
The code block below is an example of the full working expression to generate a random round number between 0 to 50.
Round(Random() * (0 - 50) + 50 , 0)
  1. Click Verify to run a test of the expression. If the expression is valid, click Apply.
The Label Class pane in ArcGIS Pro
  1. In the Contents pane, right-click the feature class and click Label to enable labeling of the layer.
The Contents pane in ArcGIS Pro

The image below displays the map with random numbers on the polygon features.

The map in ArcGIS Pro with randomized digit labels on each polygon

Article ID: 000030976

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 9x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options