<?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: Centroid and beginning/ending vertices (nodes) with Arcade (and other questions) in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140195#M305</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;It works, but it appears to be calculating the centroid for the boundary geometry of the feature rather than the actual centroid of the linear feature (i.e. actually a point ON the line). Suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Hmmm. I believe snapping the "false" centroid to the closest line segment would not yield the "correct" centroid, right?&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;As for the beginning and ending vertices X,Y, I am at a loss&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;// the geometry of line features has a "paths" attribute, which is a list of
// lists of points (multiple line segments)
// for polygons, the attribute is named "rings".
var first_point = Geometry($feature).paths[0][0]
var last_point = Geometry($feature).paths[-1][-1]
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to calculate a spatial relationship with Arcade? (Again, being new to this, this may be a no brainer). For instance, if I plot a point that is within the geometry of a polygon, I would like to do some equivalent of a spatial join to assign the point attribute(s) from the polygon.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;// load the polygons using one of the FeatureSetBy* functions
var fs_polygons = FeatureSetByName($datastore, "PolygonFC")
// find polygons intersecting the $feature
var intersecting_polygons = Intersects(fs_polygons, $feature)
// no polygons found -&amp;gt; return early
if(Count(intersecting_polygons) == 0) { return null }
// intersecting_polygons is a feature set, we want to access the attributes 
// of polygon features, so we have to extract one of them. 
// easiest, but not always appropriate, way is to just grab the first one.
var polygon = First(polygons)
// return some attribute
return polygon.Attribute
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you didn't know yet, the Arcade functions and classes are pretty well documented:&lt;/P&gt;&lt;P&gt;Arcade functions:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank"&gt;Function Reference | ArcGIS Arcade | ArcGIS Developer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Arcade classes:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/arcade/guide/types/" target="_blank"&gt;Type System | ArcGIS Arcade | ArcGIS Developer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 07:31:10 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-02-03T07:31:10Z</dc:date>
    <item>
      <title>Centroid and beginning/ending vertices (nodes) with Arcade (and other questions)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140125#M304</link>
      <description>&lt;P&gt;Greetings Attribute Rules community.&lt;/P&gt;&lt;P&gt;Though a long-time GIS user, I am new to both Attribute Rules and Arcade.&lt;/P&gt;&lt;P&gt;I have what I believe to be a fairly simply problem and hope someone can help.&lt;/P&gt;&lt;P&gt;I have a colleague who would like me to develop a field map for her that includes a linear feature called transects. She then needs to derive the starting vertex X,Y, centroid X,Y, and ending vertex X,Y of the newly created feature. I figured that an attribute rule that automatically calculates it would be great.&lt;/P&gt;&lt;P&gt;The centroid rule seemed pretty easy--Round(Centroid($feature).X, 6) and Round(Centroid($feature).Y, 6) to calculate the X and Y centroids, respectively. Hurray. Well, no.&lt;/P&gt;&lt;P&gt;It works, but it appears to be calculating the centroid for the boundary geometry of the feature rather than the actual centroid of the linear feature (i.e. actually a point ON the line). Suggestions?&lt;/P&gt;&lt;P&gt;As for the beginning and ending vertices X,Y, I am at a loss. I can use something like Round(Geometry($feature).Y, 6) to find the coordinate of a point, but how can I implement this for a vertex in a line or polygon?&lt;/P&gt;&lt;P&gt;Lastly, and this is more philosophical, I suppose. Is there a way to calculate a spatial relationship with Arcade? (Again, being new to this, this may be a no brainer). For instance, if I plot a point that is within the geometry of a polygon, I would like to do some equivalent of a spatial join to assign the point attribute(s) from the polygon.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 23:24:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140125#M304</guid>
      <dc:creator>ToddFagin</dc:creator>
      <dc:date>2022-02-02T23:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Centroid and beginning/ending vertices (nodes) with Arcade (and other questions)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140195#M305</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;It works, but it appears to be calculating the centroid for the boundary geometry of the feature rather than the actual centroid of the linear feature (i.e. actually a point ON the line). Suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Hmmm. I believe snapping the "false" centroid to the closest line segment would not yield the "correct" centroid, right?&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;As for the beginning and ending vertices X,Y, I am at a loss&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;// the geometry of line features has a "paths" attribute, which is a list of
// lists of points (multiple line segments)
// for polygons, the attribute is named "rings".
var first_point = Geometry($feature).paths[0][0]
var last_point = Geometry($feature).paths[-1][-1]
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to calculate a spatial relationship with Arcade? (Again, being new to this, this may be a no brainer). For instance, if I plot a point that is within the geometry of a polygon, I would like to do some equivalent of a spatial join to assign the point attribute(s) from the polygon.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;// load the polygons using one of the FeatureSetBy* functions
var fs_polygons = FeatureSetByName($datastore, "PolygonFC")
// find polygons intersecting the $feature
var intersecting_polygons = Intersects(fs_polygons, $feature)
// no polygons found -&amp;gt; return early
if(Count(intersecting_polygons) == 0) { return null }
// intersecting_polygons is a feature set, we want to access the attributes 
// of polygon features, so we have to extract one of them. 
// easiest, but not always appropriate, way is to just grab the first one.
var polygon = First(polygons)
// return some attribute
return polygon.Attribute
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you didn't know yet, the Arcade functions and classes are pretty well documented:&lt;/P&gt;&lt;P&gt;Arcade functions:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank"&gt;Function Reference | ArcGIS Arcade | ArcGIS Developer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Arcade classes:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/arcade/guide/types/" target="_blank"&gt;Type System | ArcGIS Arcade | ArcGIS Developer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 07:31:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140195#M305</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-02-03T07:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Centroid and beginning/ending vertices (nodes) with Arcade (and other questions)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140334#M306</link>
      <description>&lt;P&gt;I appreciate your assistance on this. I see I still have a lot to do to completely wrap my head around Attribute Rules and Arcade.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 15:39:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/centroid-and-beginning-ending-vertices-nodes-with/m-p/1140334#M306</guid>
      <dc:creator>ToddFagin</dc:creator>
      <dc:date>2022-02-03T15:39:32Z</dc:date>
    </item>
  </channel>
</rss>

