<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Auto Counter based on Polygon in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1474120#M8664</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/723956"&gt;@JPWillson&lt;/a&gt;&amp;nbsp;I did some more testing and I came up with this. You will need to make a few changes based on your data, let me know if you have any questions.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Feature set of your park/polygon boundary
var park = FeatureSetByName($map, "Boundaries")

//Feature set of your flag layer
var flags = FeatureSetByName($map, "Flags")

//finding the nearest park/polygon, the park/polygon the point falls in
var nearestPark = First(Intersects($feature, park))

//Count of points falling in that polygon
var countFlags = Count(Intersects(flags, nearestPark))

//return the park name with a count, and adding one to the count, to account for the new point being added, if no flags, return null
If (IsEmpty(countFlags)){
  return null
}else{
return nearestPark.Name + " " + (countFlags + 1)
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 16 May 2024 19:38:00 GMT</pubDate>
    <dc:creator>KerriRasmussen</dc:creator>
    <dc:date>2024-05-16T19:38:00Z</dc:date>
    <item>
      <title>Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1466429#M8644</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to make an Arcade expression that automatically counts up flags placed inside of a polygon. I attempted to grab the counting portion from another user but that aspect of the expression continues to fail. The intersect portion also does not seem to be working correctly. I have attached a sample code. Any suggestions/advice would be greatly appreciated! Thanks in advance.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;If (IsEmpty($feature.Flag)) {
var numberlist = FeatureSetByName ($map, "Wetland")
var topnum = Top(OrderBy(numberlist, 'Flag DESC'), 1)
var counter = Number(max(topnum, 'Flag))
var Flag = counter + 1

var polygons = FeatureSetByName($map, "Boundary")
var i_polygon = First(Intersects(polygons, $feature))
if(i_polygon == null) {return null}
}
return i_polygon.Name + Flag&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 May 2024 16:42:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1466429#M8644</guid>
      <dc:creator>JPWillson</dc:creator>
      <dc:date>2024-05-14T16:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1472854#M8653</link>
      <description>&lt;P&gt;Assuming you are adding this calculation to your boundary layer (or the polygon layer where you want to count the flags) try this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;flags&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$map&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Flag"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;countFlags&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Intersects&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;flags&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;countFlags&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 May 2024 13:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1472854#M8653</guid>
      <dc:creator>KerriRasmussen</dc:creator>
      <dc:date>2024-05-15T13:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1473800#M8662</link>
      <description>&lt;P&gt;Thank you for your reply. I am attempting to add this calculation to the Flag feature so I can use it to automatically count the flags so numbers are not skipped. As an example, I am doing a wetland delineation in "State Park". I want the field to calculate such that every time I add a point in FieldMaps, the form looks for an intersection with the boundary layer and records that intersection and then adds a number to the end. Something like StatePark 1, StatePark 2, etc. Thank you for your assistance and apologies for the misunderstanding.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 13:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1473800#M8662</guid>
      <dc:creator>JPWillson</dc:creator>
      <dc:date>2024-05-16T13:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1473848#M8663</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/723956"&gt;@JPWillson&lt;/a&gt;&amp;nbsp;I haven't done any additional testing yet, but I did just notice the 'Flag' on line 4 in your expression is missing a '.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 14:23:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1473848#M8663</guid>
      <dc:creator>KerriRasmussen</dc:creator>
      <dc:date>2024-05-16T14:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1474120#M8664</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/723956"&gt;@JPWillson&lt;/a&gt;&amp;nbsp;I did some more testing and I came up with this. You will need to make a few changes based on your data, let me know if you have any questions.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Feature set of your park/polygon boundary
var park = FeatureSetByName($map, "Boundaries")

//Feature set of your flag layer
var flags = FeatureSetByName($map, "Flags")

//finding the nearest park/polygon, the park/polygon the point falls in
var nearestPark = First(Intersects($feature, park))

//Count of points falling in that polygon
var countFlags = Count(Intersects(flags, nearestPark))

//return the park name with a count, and adding one to the count, to account for the new point being added, if no flags, return null
If (IsEmpty(countFlags)){
  return null
}else{
return nearestPark.Name + " " + (countFlags + 1)
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 May 2024 19:38:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1474120#M8664</guid>
      <dc:creator>KerriRasmussen</dc:creator>
      <dc:date>2024-05-16T19:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1478703#M8723</link>
      <description>&lt;P&gt;Kerri,&lt;/P&gt;&lt;P&gt;Thank you again for assistance. I am trying to use this as an expression for a FieldMap so the wetland features are being created as one is collecting data. I would like the wetland features to be collected as a polygon. As wetland polygons are created, I would like the expression to grab the polygon from the boundaries. Then the count portion would be counting each discrete polygon as they are created. Example: Washington Park 1 would be the first wetland polygon closed in Washington Park.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2024 01:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1478703#M8723</guid>
      <dc:creator>JPWillson</dc:creator>
      <dc:date>2024-05-25T01:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Counter based on Polygon</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1484193#M8791</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//Feature set of your park/polygon boundary&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;park&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$map&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Boundaries"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;//Feature set of your wetlands layer&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;wetlands&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$map&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"WetlandArea_Test"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;//finding the nearest park/polygon, the park/polygon the point falls in&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;nearestPark&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;First&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Intersects&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;park&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;//Count of polygons falling in the park polygon&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;countWetlands&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Intersects&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;wetlands&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;nearestPark&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;//return the park name with a count, and adding one to the count, to account for the new point being added, if no wetland areas, return null&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;countWetlands&lt;/SPAN&gt;&lt;SPAN&gt;)){&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;null&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;nearestPark&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Name&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;" "&lt;/SPAN&gt;&lt;SPAN&gt; + (&lt;/SPAN&gt;&lt;SPAN&gt;countWetlands&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Jun 2024 11:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/auto-counter-based-on-polygon/m-p/1484193#M8791</guid>
      <dc:creator>KerriRasmussen</dc:creator>
      <dc:date>2024-06-04T11:58:35Z</dc:date>
    </item>
  </channel>
</rss>

