How can we help? How can we help?
How can we help?

Drop us a line and we’ll get back to you asap!

    Thank you for your inquiry with DVG! We will reach out as soon as possible.

    The first part of this blog post demonstrated how you can use Arcade to add attributes to a layer’s pop-up from a related record, including attributes calculated from the related record.  The second part of this post will show how you can add new attributes from other unrelated layers in the map using a common attribute and by performing an on-the-fly spatial overlay with Arcade. The ArcGIS Online web map I am using includes addressing data from Hudson County, New Jersey: an Address points layer with a related table of Units at each address that was used in the first part of this blog post.  It also has the Statewide Parcels and MOD-IV Composite feature service hosted by New Jersey’s Office of GIS (NJOGIS) that consists of polygon parcel boundaries and associated property information in the attribute table.

    ArcGIS Online web map showing layer pop-up with attributes created using Esri Arcade scripting language

    Attributes from a Common Value

    The Address Units table has minimal data in it, just the unit value and the address ID field to link back to the Hudson County Addresses layer where the majority of the addressing information is stored for each point.  In the previous blog post I showed how to add new attributes to the layer’s pop-up from the related points layer including Street Address, Municipality, County, and coordinates.  I would also like to add attributes from a Mailing Addresses table in the map that is unrelated to the address points and units data.  Arcade can help here because the data have a common attribute, Address ID. Here is the Arcade expression for adding the Postal Code attribute from the unrelated Mailing Addresses table to the Units pop-up:

    Arcade script utilizing FeatureSet function to access attributes from a layer with a common attribute; Esri Arcade expression language

    First, define a variable for the common attribute field.
    var addr_id = Text($feature.ADDR_ID);

    Then, access the Address Point layer using a FeatureSet function but this time I’m using FeatureSetByName which creates a FeatureSet from a layer based on its name in the web map.
    var addr_fs = FeatureSetByName($map,"Mailing Addresses");

    Then, construct a SQL expression to query the FeatureSet, which currently includes all features in the Mailing Addresses layer.
    var sql = "ADDR_ID='" + addr_id + "'";
    console (sql);

    Use the console function to check to make sure the SQL statement appears correctly before continuing. When you click Test you can view the console output in the Messages tab of the expression editor:

    Arcade expression editor window showing script test with console function; Esri Arcade expression language

    The console message displays the sql variable string and it is displaying correctly.

    Next create the add_filter variable and use the Filter function to query the addr_fs FeatureSet with the SQL statement for records with the same Address ID.
    var addr_filter = Filter(addr_fs, sql);
    // return the attribute of interest
    var Post_Code = First(addr_filter).POST_CODE;
    return Post_Code;

    Attributes from Spatial Overlay

    So now there is more address information in the Units pop-up but I would like to add some basic property information to the Hudson County Addresses layer pop-up. However, there is no property information in the address point.  The New Jersey statewide parcel layer contains all property, ownership, and taxation information.  The Address Point and Unit table layers are local within my AGO organization, so there is no relationship or join to the parcel layer in the other AGO organization.  I could have performed a spatial join analysis in ArcGIS Online or in ArcGIS Pro before publishing to add these fields to my data but then I would have to keep the parcel data in sync with the authoritative source. My dataset would also be larger, though not significantly, and would require more credits to host on ArcGIS Online.

    Thankfully, I do not need to add the relevant fields from the parcel data to my address points.  I can add data directly from the parcel data hosted and maintained by NJOGIS to my address pop-up using Arcade. Here is the expression for returning the PAMS_PIN value from the parcels layer to the Address Point pop-up.

    Arcade script utilizing FeatureSet function to access attributes from a layer by spatial overlay; Esri Arcade expression language

    Once again use the FeatureSetByName to access another layer in the web map.
    var addr_fs = FeatureSetByName($map,"NJ Parcels");

    Then use the Intersects function to find the features in the parcel FeatureSet that intersects with the given $feature in the Hudson County Addresses point layer.  In the same line of code use the First function so that the variable prop is a single record rather than a FeatureSet. Lastly, declare a variable for the PAMS_PIN field and return it as the value for this script.

    Here’s the ArcGIS Online web app showcasing the pop-ups with attributes created using Arcade. You can view the web app here also.


    Be sure to check out the first part of this blog for more useful tips on using Arcade to power your AGO pop-ups.

    Categories: ArcGIS, Blog, Esri, GIS
    Using ArcGIS Arcade to Power your Pop-Ups: Part 2

    Share On:

    Verified by MonsterInsights