ArcGIS Collector

Use barcodes and Arcade expressions in Collector

When working in the field, typing information is often tedious and a source of collection errors.  While there are many ways to improve the efficiency of collecting attribute information, one of the most useful is through using barcodes.  We find barcodes on many items, from cereal boxes to books.  Capturing barcodes is fast, accurate, and doesn’t require any additional equipment. In this blog post we’ll show you how to quickly capture barcodes in Collector. In addition, we’ll use arcade expressions to decipher information stored in the barcode to make it available immediately to those in the field as well as the office.

The natural gas industry in the US is required to be able to identify information for any gas distribution component.  This includes production date, manufacturer, component size or sizes for a given gas distribution components encoded using the ASTM F2897 standard. The specification defines requirements for the data and the format of the resultant barcode to characterize various components used in fuel gas piping systems. Each gas component has a printed barcode that stores this information in a compact manner.  Unfortunately, the compact nature means it is difficult to understand the information it contains.

In this example we are capturing the barcode on a gas component in the field using Collector. We’ll use a series of Arcade expressions to make the information available in the field, even when disconnected.  In addition, this is also available to others inside or outside the organization.

Capturing the barcode

Let’s start off by capturing a barcode for a new gas service line.  From within Collector it’s easy to access the barcode scanner and populate any text or numeric field. In our case we’re using a field specifically intended to store the scanned barcode value. This is a really efficient way to accurately capture information about an asset in the field.  Once we’ve scanned the barcode, we submit the edit.

Let’s take a look at the resulting popup, paying specific attention to the Component Details section as well as the title. This displays all the information we’ve derived from the barcode, such as the production date and lot number.

 

Extracting information from the barcode with Arcade

Each piece of information is extracted from the barcode using an Arcade expression. These expressions can be used within the popup, as well as labels to display the result.  The following Arcade expression extracts the lot number from the barcode.


var base62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

var BARCODE = $feature.BARCODE;

// extract the encoded lot number from the barcode
var lotnumberEncoded = Mid(BARCODE,2,4);

// unencode the lot number
var manufacturerLotCode = 0;
for (var z=0;z < Count(lotnumberEncoded);z++) {
  manufacturerLotCode = manufacturerLotCode * Count(base62) +
    Find(Mid(lotnumberEncoded,z,1), base62);
};

return (manufacturerLotCode);

The Arcade expressions are processed immediately in Collector, even when working offline.  All of the Arcade expressions used to decode the barcode are available on Github.

Testing the solution

Want to give it a try yourself?  Head over to our Try It account and open the Gas network map.

Open the Gas Network map.  Scan this example barcode in Collector, and view the information in the popup once you submit your feature.

Summary

This is just one example of how you can use barcodes in your field data collection workflows. Give them a try, increase the productivity of your asset inspections, and unlock the information for the organization to easily access.

More Information

Learn more about how to take advantage of Collector as part of a broader tracking and traceability solution for gas utilities in this GeoNet post.

Arcade developer reference

Capturing barcodes in Collector

About the author

Doug is the Product Owner for Collector for ArcGIS. He works to extend the reach of GIS to include the mobile workforce to help organizations make quicker, more informed decisions.

Connect:

Next Article

Dig into the 2022 U.S. Census of Agriculture

Read this article