ArcGIS Blog

Mapping

ArcGIS Online

Professional Pop-Ups: Handling Missing Data

By Rich Nauman

When working with environmental data we often find that values for some attributes are missing from a portion of the features. Maybe the layer was created from historical records of varying detail or maybe some fields are not applicable to all records.

Regardless of the reason, missing values can provide a poor pop-up experience. Handling these missing values with ArcGIS Arcade is a great way to take your pop-ups to the next level.

Recently I published a feature layer based on the Geologic Map of North America. After publishing the layer, I enabled pop-ups, clicked the map, and got this:

Default pop-ups are OK for a quick map but are difficult to read and interpret.

It’s not the greatest design. The OBJECTID field starts the pop-up and scrolling down leads the user to the Shape_Area and Shape_Length field with a bunch of blank fields in between. “Miocene” is repeated 3 times and the user is left without a clear picture of what the map is trying to tell them. There is no indication of relative importance in the values and the pop-up shows no consideration of what questions the user has about the map.

Here is what I did to improve things. To start, I removed fields that we don’t need and added a little formatting. I like to leave the title blank and use font size, weight, and text properties to create an informational hierarchy within the body of the pop-up that serves as a title:

Two minutes of formatting makes a huge difference, but the blank fields detract from the pop-up.

Next, I tried a version without labels with less than satisfactory results:

Blank lines remain even when there is no data leaving empty areas in the pop-up.

ArcGIS Online maintains the lines for the missing values because I hit return at the end of each line. If you look in the html view (click the “<>” in the custom pop-up configuration window) you can see the “<br/>” tags that tell online to insert a new line.

The field I use for the title (Esri Symbology), the Unit Code in the second line of the pop-up, and Rock Type all have values for every record, so we don’t have this issue with those fields. Lithology is another story. I used the Data Engineering view in ArcGIS Pro to calculate statistics for the field and discovered that nearly half the records (46.6%) are null.

The simple solution is the character for a new line “\n”. A simple Arcade expression can tell your pop-up to add a new line where there is data and to not add a new line if there is no data. The code looks like this:

Note that you could use TextFormatting.NewLine instead of \n for the same effect. I tend to use \n because its easier to type.

The Arcade IIf function forms the foundation of this expression. It is simple and works like this:

IIf(
a conditional expression that is true or false,
return this value if true,
return this value if false
)

The IIF function starts with a conditional expression. In this case I use the IsEmpty function in line 2 to check if Lithology has a value. If the IsEmpty function is true (there is no value in the Lithology field for that record) then the code returns an empty string indicated by the pair of double quotes in the 3rd line. If the IsEmpty function is false (there is a value in the Lithology for that record) the code returns the Lithology value with a “\n” added to the end of the text. Note that I use the Proper function to capitalize the first letter of each word.

This feature has no value for Lithology and the Arcade expression does not put a blank line between “Sedimentary” and “Paleozoic” in the pop-up.

This feature has a Lithology value so the Arcade expression adds a new line and inserts the text “Mafic Rocks” after “Volcanic” and before “Quaternary”.

To configure the pop-up I used the Arcade expression value from the code we just wrote ({expression/expr0}) and did not put a line return in my configuration. The Arcade output already has a line return if we need it. You can see where “{MIN_AGE}” follows immediately after “{expression/expr0}” in the configuration window.

Notice that in the custom configuration window there is no line return after the Lithology value {expression/expr0}. This allows Arcade to insert a line when we have a Lithology value and not insert a line when there is no Lithology value.

Age Uncertainty and Unit Uncertainty are a little more complicated. Less than 100 of our almost 40,000 features have a “Y” value for the Unit Uncertainty field and only about 200 have a “Y” value for the Age Uncertainty field. The rest of the features have null values for these fields. While only a small number of features have values this information may be important for the map user.

In my finished pop-up I want a blank line after the uncertainty values so use “/n/n” instead of the single “/n”.

The IIF function is used to check if the feature has an Unit Uncertainty value. If it is null the expression returns an empty string otherwise it returns “Unit Composition or Origin Uncertain/n/n”. Note that the double /n/n adds a blank line after the text.

This one is a little more complex. The Age Uncertainty value will have a single new line  if there is a Unit Uncertainty value and two new lines if there is a value. The first 6 lines check the Unit Uncertainty and return either a single or double new line. Lines 8-12 check if Age Uncertainty is empty and returns an empty string if it is. If Age Uncertainty has a value it returns “Age Uncertain” plus either the single or double new line depending on the Unit Uncertainty field.

This feature has a “Y” value for the Age Uncertainty and Unit Uncertainty fields. The two Arcade expressions add the text followed by a blank line. No features have values in the Notes field and both the uncertainty fields so we get a large blank space at the bottom of the pop-up.

This feature has a “Y” for the Age Uncertainty field and the Unit Uncertainty field is null. The two Arcade expressions add a single line of text and a blank line followed by the Notes field value.

We face another problem when we get to the age fields. You can see that the value “Paleozoic” appears twice in the pop-up above. The attribute table provides us a field for maximum age, a field for minimum age, and a relationship field to connect the two age fields. If the maximum and minimum fields are the same the relationship field is blank. If we just display these three values in order we end up with the same value twice with no conjunction between them.

Three fields from the attribute table give us minimum and maximum age plus a field to connect them. Records where minimum and maximum age are the same have no value in the relationship field.

 In this case we use the IsEmpty function to check if the Age Relationship field is empty (line 2). If the Age Relationship is empty then we return the Maximum Age value (line 3) but if it is false the we use the Concatenate function to combine the Maximum Age, the Age Relationship value, and the Minimum Age (lines 4-9):

A simple bit of Arcade checks if the age fields indicate a single value or a range of values and formats a line for the pop-up appropriately.

Finally, I used a simple expression to handle null values in the Notes field, centered all the text, and added a hyperlink to the bottom of the pop-up. The configuration looks like this:

Which gives us a pop-up that looks like this:

A well-crafted pop-up helps answer a user’s questions about the map and provides a neat, professional appearance that compliments your cartography.

Take a few minutes and explore the new Geology of North America layer. You can open the pop-up configuration and explore the Arcade expressions. Steal them, modify them, or make something even better!

Share this article

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments