<?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: Calculate Polygon Centroid Coordinates in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316461#M36784</link>
    <description>&lt;P&gt;here's the arcade expression that you can add in the attribute rules, you'll need to add a rule for each field and set the 'triggering' event that calculates it (insert, update, or delete).&lt;/P&gt;&lt;P&gt;centroid($feature).x&lt;/P&gt;&lt;P&gt;Here's a help article on this topic too - this shows examples using points but the centroid function should get you what you need.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-calculate-xy-values-using-arcade-in-arcgis-pro-000028012" target="_blank"&gt;How To: Calculate XY Values Using Arcade in ArcGIS Pro (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here is a reference to Arcade Functions that can be very helpful:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank"&gt;Function Reference | ArcGIS Arcade | ArcGIS Developers&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 15:10:48 GMT</pubDate>
    <dc:creator>clt_cabq</dc:creator>
    <dc:date>2023-08-08T15:10:48Z</dc:date>
    <item>
      <title>Calculate Polygon Centroid Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316334#M36777</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create an attribute rule to automatically calculate the centroid x and y coordinates of polygons from one layer. I managed to add the x and y centroid coordinates in decimal degrees using the "Calculate Feature Geometry" tool, then "centroid x/y-coordinates".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since this layer is populated by my colleagues, I want to create an attribute rule that will do this automatically when a new feature is added or an existing one is edited. I already created 2 specific fields "X" and "Y" in which I added the centroid coordinates using the geoprocessing tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone explain to me how I can create an Arcade expression that will calculate the centroid x/y coordinates of the polygons? Also, I would like to be stored in my X and Y fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. I don't want to create any centroid point, I just want the centroid coordinates as the geoprocessing tool does.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 11:31:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316334#M36777</guid>
      <dc:creator>MariusVerdes</dc:creator>
      <dc:date>2023-08-08T11:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Centroid Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316461#M36784</link>
      <description>&lt;P&gt;here's the arcade expression that you can add in the attribute rules, you'll need to add a rule for each field and set the 'triggering' event that calculates it (insert, update, or delete).&lt;/P&gt;&lt;P&gt;centroid($feature).x&lt;/P&gt;&lt;P&gt;Here's a help article on this topic too - this shows examples using points but the centroid function should get you what you need.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-calculate-xy-values-using-arcade-in-arcgis-pro-000028012" target="_blank"&gt;How To: Calculate XY Values Using Arcade in ArcGIS Pro (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here is a reference to Arcade Functions that can be very helpful:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank"&gt;Function Reference | ArcGIS Arcade | ArcGIS Developers&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 15:10:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316461#M36784</guid>
      <dc:creator>clt_cabq</dc:creator>
      <dc:date>2023-08-08T15:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Centroid Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316892#M36793</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/663332"&gt;@clt_cabq&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your answer. I tried to use your first expression "&lt;SPAN&gt;centroid($feature).x" but it return the coordinates in meters and I want them to be in decimal degrees.&lt;BR /&gt;&lt;BR /&gt;Then I tried to use the How to guide provided, and when I tried it, it returns 0 as a value. Maybe I did something wrong..but the expression was validated. Here is my expression: X = "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;//To populate X coordinate in decimal&lt;/P&gt;&lt;P&gt;function MetersToLon(x) {&lt;/P&gt;&lt;P&gt;var originShift = 2.0 * PI * 6378137.0 / 2.0;&lt;/P&gt;&lt;P&gt;var lon = (x / originShift) * 180.0;&lt;BR /&gt;&lt;BR /&gt;return Round(lon, 3);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return MetersToLon(Round(Geometry($feature.X), 6));"&lt;/P&gt;&lt;P&gt;and Y "&lt;/P&gt;&lt;P&gt;//To populate Y coordinate in decimal:&lt;/P&gt;&lt;P&gt;function MetersToLat(y) {&lt;/P&gt;&lt;P&gt;var originShift = 2.0 * PI * 6378137.0 / 2.0;&lt;/P&gt;&lt;P&gt;var lat = (y / originShift) * 180.0;&lt;/P&gt;&lt;P&gt;lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);&lt;BR /&gt;return Round(lat,3);&lt;BR /&gt;}&lt;BR /&gt;return MetersToLat(Round(Geometry($feature.Y), 6));"&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1316892#M36793</guid>
      <dc:creator>MariusVerdes</dc:creator>
      <dc:date>2023-08-09T14:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Centroid Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1474559#M39522</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/647934"&gt;@MariusVerdes&lt;/a&gt;&amp;nbsp;you can modify your Arcade expression according to the second example in the article linked below (which is very similar to what you are using) to get the coordinates of the centroid of a polygon in degrees.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/000028324" target="_blank"&gt;https://support.esri.com/en-us/knowledge-base/000028324&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hopefully this sample expression resolves the issue for you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 14:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1474559#M39522</guid>
      <dc:creator>MJBiazar</dc:creator>
      <dc:date>2024-05-17T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Centroid Coordinates</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1479319#M39606</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/133181"&gt;@MJBiazar&lt;/a&gt;. Meanwhile, I managed to resolve the situation with the help of our local Esri provider.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 08:07:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/calculate-polygon-centroid-coordinates/m-p/1479319#M39606</guid>
      <dc:creator>MariusVerdes</dc:creator>
      <dc:date>2024-05-28T08:07:02Z</dc:date>
    </item>
  </channel>
</rss>

