Arcade newbie

115
3
04-03-2020 09:29 AM
Highlighted
New Contributor II

My map viewer includes two layers that have census tract data. One is my layer, which has these attributes:

GEOID
Change_2018_2010

2010_count
2018_est

Per_change

I'd like to add those attributes to the already existing/formatted/lovely popup that comes with the Living Atlas ACS Race and Hispanic Origin by tract. They both share the GEOID attribute, so I thought the guidance in this blog post is most relevant.

Pump up Your Pop-ups With Arcade FeatureSets and the Living Atlas 

But I can't figure it out.

I'm a complete newbie to programming languages and Arcade. I've been reading blogs and watching the videos but I'm not making any progress. I could certainly join the layers in Desktop and move on, but I'd like to learn Arcade. I can't find a learning pathway that assumes you are a complete beginner. This blog post referenced above seems to be the most relevant, and I've stared at it for hours, but I'm not getting anywhere. 

Tags (1)
Reply
0 Kudos
3 Replies
Highlighted
Esri Esteemed Contributor

Hi Tricia Hines , 

Have you explored the available lessons at learn.arcgis.com? Lesson Gallery | Learn ArcGIS  There are a couple that should get you started. To help you with your particular challenge, I have some instructions below.

Let me take you through the steps. To simulate your situation I added two layers of the living atlas that both share the GEOID. I will work on the Tract level to explain the process:

The pop-up by default has the following information:

We can edit this pop-up bu adding additional information to it. To do so we have to configure an expression on the layer to access your layer and retrieve the information you want to add. So enter the configuration of the pop-up and click on the Add button to configure the Arcade expression:

And this is were you start writing your expression:

The expression used in my example you can find below (please read the comments to understand each step):

// Change_2018_2010
// 2010_count
// 2018_est
// Per_change

// read your GEOID from the feature you clicked on
var geoid = $feature.GEOID;
// create a filter expression
var sql = "GEOID = @geoid";
// connect to your layer (change the name of the layer as used in the map)
var fs = FeatureSetByName($map,"ACS Population Variables - Boundaries - Tract");
// filter the features by GEOID
var tracts = Filter(fs, sql);

// create a string variable to store the result
var result = "Info on your other layer:";
// check to see if we have resulting records, using a count
if (Count(tracts)>0) {
// we have results, get the first record (there will probably only one)
var tract = First(tracts);
// construct the string, use the names of the field you want to return
var total_area = tract.ALAND + tract.AWATER;
result += TextFormatting.NewLine + " - Land area : " + tract.ALAND + " (" + Round(tract.ALAND/total_area * 100, 2) + "%)";
result += TextFormatting.NewLine + " - Water area: " + tract.AWATER + " (" + Round(tract.AWATER/total_area * 100, 2) + "%)";
} else {
// no records found with the GEOID, result empty string
result = "";
}

return result;

To show the result you will have to add the expression to the pop-up. To do this configure the pop-up:

And add the expression to the pop-up:

Hit "OK" and see the result:

In your case you will consult the fields you mentioned. 

Be aware that you will need to configure the expression for each layer that you use and access the correct corresponding layer in case you have different levels of aggregation.

Highlighted
New Contributor II

Thank you, Xander Bakker‌! That worked! I really appreciate you walking me through that. And it's helpful to know that I wasn't too far off. Yes, I have explored the lesson gallery and thought I hit all the relevant lessons, but I will look again. 

Highlighted
Esri Esteemed Contributor

Hi Tricia Hines ,

I'm glad it worked. If you already worked through the learn lessons, you might want to look at some blog post that have been shared by Esri: You searched for | ArcGIS Blog 

On GeoNet there are also a number of posts. Mine are mostly in Spanish, but there are a couple in English that might be interesting to have a look at: 

Can you mark the post that answered your question as the correct answer? This helps other user to find this content easier. 

Reply
0 Kudos