arcade expression for label the numbers of permits by neighborhood

3196
9
Jump to solution
11-23-2020 07:50 AM
Labels (1)
DianaWilson1
New Contributor III

Hi All,

I am working an arcade expression for label the numbers of permits open by neighborhood. Each permit is assign to each parcel within the Neighborhood. The parcel Identification number is a "text" data type and a duplicate parcel identification in the attribute table means that there are more than one permit open on the property. I wrote this expression, but it does not work how it is expected. Using the counts function, I got number “1”for each permit in each parcel, but I cannot sum the counts. I want to display the total number of permit per neighborhood.

Could you please review it and let me know how will be the right expression. Any advice? thank you!

SUM(count([$feature.PARID]))

1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,


Related to the first part of your response, I guess this should also be possible to achieve using the condo complex. Let me know if you want to explore that option.

To learn Arcade I think the book should be a very good resource, although I haven't seen the content in detail. Arcade in for instance a web map is something that is not very advanced. However, using arcade in attribute rules is a topic that can be advanced depending on what you want to achieve. There is a community in GeoNet focussed on attribute rules: https://community.esri.com/t5/attribute-rules/ct-p/attribute-rules  

Also, the examples in the help documentation are very helpful: https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/attribute-rule-script-expression.h...  

I would also recommend the various blogs published by Esri: https://www.esri.com/arcgis-blog/?s=#arcade
There are also learn lessons for Arcade: https://learn.arcgis.com/en/gallery/#?q=arcade  

And last but not least all the blogs and documents published here at GeoNet that can provide insight in how to do something: https://community.esri.com/t5/forums/searchpage/tab/message?filter=includeBlogs,includeTkbs&q=arcade...  

View solution in original post

9 Replies
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,

 

The reason that you obtain the value 1 is this: $feature.PARID is a single value and when you "count" a single value you get 1 and when you do a sum of 1 you also get 1. 

 

What you want to do to either read out the neighborhood id or obtain it using Intersects and filter the data using the id to get all the permits in the neighborhood. Is the permits information spatial or just a table. If it is spatial and represented using the parcels you can use a spatial operation to get all the permits if you both have the permit locations and the neighborhood polygons. If not, you would probably have to use some attribute to know how to filter the data and get the amount of permits in the area. Can you explain a little more what your situation is?

 

Tags (1)
DianaWilson1
New Contributor III

The permits information is spatial and it is represented with the parcels polygons. They can be more than one permit per parcel.

You suggestion is to use the label funtion:

var geom2 = Polygon({...})
Count( Intersects($feature.NBHD, geom2) );

Using this one, I got an error "Invalid key". I am getting familiar with all the label funtions, but I haven't use this one. Any advice? Thank you!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,

 

If your goal is to label features (sorry I had not noticed that when I replied previously), you will need to create a field and store the result of an análisis in that field (you could use Arcade with a field calculation). The label profile is very limited and does not allow you to access other features and do these types of aggregations. You can include it in the pop-up using Arcade without creating the field.

So if you can indicate if you really need labels and are able to add another field, or are open to showing the information dynamically in the pop-up then we can have a look at t he options.

0 Kudos
DianaWilson1
New Contributor III

Hi Alex,


Thank you! I won't be able to add another field. The data is storage using is a URL that programmer created and I will share this map though portal.
It is a great idea to include the permit count by NBHD using the pop-up window! Please looking this option, what will be your advice? Thank you!

 

 

 

 

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,

 

In the pop-up you can create an Arcade expression on the neighborhood layer and find all the permits that spatially intersect the neighborhood and do a count on that and return the number of permits. 

It can be something as simple as this:

// access the layer that contains the permits
var fs = FeatureSetByName($map, 'Name of the permits layer in the TOC');

// intersect with the neighborhood feature and count the number of permits
var permits = Count(Intersects(fs, $feature));

// return the number of permits
return permits;

 

However, the solution depends on how your permits are stored.

0 Kudos
DianaWilson1
New Contributor III

Thank you. I used the query below, but I got an error. "Geometry type expected" using the "$feature.NBHD". Then, I try with the "$feature.PARID". the data source of this layer is a Feature Service and the geometry type is "esriGeometryPolygon"

// access the layer that contains the permits
var fs = FeatureSetByName($map, 'PAPermits_Y0');

// intersect with the neighborhood feature and count the number of permits
var permits = Count(Intersects(fs, $feature.NBHD));

// return the number of permits
return permits;

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,

When you do an intersect, you that with a featureset and a feature. Once you specify  "$feature.NBHD" or "$feature.PARID" you don't have a feature (geometry) anymore but only the value contained in either the field NBHD or PARID. So, just try this:

// access the layer that contains the permits
var fs = FeatureSetByName($map, 'PAPermits_Y0');

// intersect with the neighborhood feature and count the number of permits
var permits = Count(Intersects(fs, $feature));

// return the number of permits
return permits;

 

DianaWilson1
New Contributor III

Hi Alex,

Thank you! The expression is valid, but it doesn't work the way that I need that. The features drawing are not by NBDH, no by PARID, it is by condo complex, so I will need to use another layer.

Thanks again! another question, where I can learn more about Arcade expressions and calculations using Arcade expressions?   I got the  book "GIS guidebook: writing arcade expression for ArcGIS Pro, by David W. Allen". I would like to get a advance knowledge in this topic and the book is like beginners to intermedium. 

Thanks and happy holidays!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @DianaWilson1 ,


Related to the first part of your response, I guess this should also be possible to achieve using the condo complex. Let me know if you want to explore that option.

To learn Arcade I think the book should be a very good resource, although I haven't seen the content in detail. Arcade in for instance a web map is something that is not very advanced. However, using arcade in attribute rules is a topic that can be advanced depending on what you want to achieve. There is a community in GeoNet focussed on attribute rules: https://community.esri.com/t5/attribute-rules/ct-p/attribute-rules  

Also, the examples in the help documentation are very helpful: https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/attribute-rule-script-expression.h...  

I would also recommend the various blogs published by Esri: https://www.esri.com/arcgis-blog/?s=#arcade
There are also learn lessons for Arcade: https://learn.arcgis.com/en/gallery/#?q=arcade  

And last but not least all the blogs and documents published here at GeoNet that can provide insight in how to do something: https://community.esri.com/t5/forums/searchpage/tab/message?filter=includeBlogs,includeTkbs&q=arcade...