HOW TO

Calculate unique identifier values similar to Global IDs

Last Published: April 25, 2020

Summary

Global ID and GUID data types store registry style strings consisting of 36 characters enclosed in curly brackets within a geodatabase. The values are normally used to track geodatabase replication; however, they can be used for other identification purposes.

The Global ID values are automatically updated when a feature is added to a geodatabase. In contrast, the GUID values must be managed manually. These values can be created through Python.

Procedure

A unique identifier can be calculated using the UUID (Universally Unique Identifier) Python module. The resulting string value can be modified to match the same format as the Global ID by applying an uppercase function with the addition of curly brackets.

  1. Add a new field to the feature class. A GUID field type can only be added to a geodatabase feature class, and a text field type can be added to a shapefile.
    Note:
    A text field requires a length of 38 characters to store the identifier, dashes, and brackets.
  2. Open the Field Calculator, choose the Python parser, and check the option to Show Codeblock.

    Pre-Logic Script Code:
    Code:
    def ID():
      import uuid
      return '{' + str(uuid.uuid4()) + '}'
    

    GUID=
    Code:
    ID()
    

    [O-Image]
     
  3. The unique value is calculated for each row:

    [O-Image]

Article ID:000011677

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic