<?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-generating and updating a centroid point layer from a polygon layer in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1390427#M57835</link>
    <description>&lt;P&gt;I am currently trying to implement an attribute rule on a polygon feature class (AG_PL) to add, update or delete a point feature (AG_PT) geometry and populate 'PolygonGUID' field in AG_PT with AG_PL's GlobalID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;AG_PL and AG_PT are in composite relationship called (AG_PL_AG_PT).&lt;/P&gt;&lt;P&gt;When I test creating a new polygon or moving an existing polygon or deleting an existing polygon I receive this message below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've reviewed the arcade expression several times but am unable to identify the Undefined Keyword.&amp;nbsp; Any help on this would be much appreciated.&amp;nbsp; Thanks!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Failed to create 4.
Undefined keyword is used in the dictionary return script. [
Rule name: Poly,
Triggering event: Insert,
Class name: AG_PL,
GlobalID: {D7E577D7-9F8F-4099-AE23-9B5DBCDD3EC3}]Undefined keyword is used in the dictionary return script. [edits]&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on polygon feature class
// field: empty
// triggers: insert, update, delete
// Push(edit_points.adds, {"geometry": p_geometry, "attributes": p_attributes})
// this object will be returned to edit the related point fc
var edit_points = {"className": "AG_PT", "adds": [], "updates": [], "deletes": []}

var mode = $editcontext.editType
var poly_guid = $feature.GlobalID
var p_geometry = Centroid($feature)
var p_attributes = {'PolygonGUID': poly_guid}


if (mode == "INSERT") {
  // if a polygon is inserted, insert a new point
  Push(edit_points.adds, {"geometry": p_geometry, "attributes": p_attributes})
} 


else {
  // find the related point(s)
  var related_points = FeatureSetByRelationshipName($feature, 'AG_PL_AG_PT')
  for(var p in related_points) {
    if(mode == "UPDATE") {
      // update geometry
      Push(edit_points.updates, {'globalID': p.GlobalID, 'geometry': p_geometry})
    }
    if(mode == "DELETE") {
      // delete point
      Push(edit_points.deletes, {'globalID': p.GlobalID})
    }
  }
}

// apply the edits
return {"edits": [edit_points]}&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 04 Mar 2024 15:34:09 GMT</pubDate>
    <dc:creator>TerrolPalmer6</dc:creator>
    <dc:date>2024-03-04T15:34:09Z</dc:date>
    <item>
      <title>Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125372#M43330</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have a webmap which displays a layer generated from responses in Survey123. In the survey users draw a polygon indicating the area of their response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the webmap I would like to display these polygons, as well as points (i.e. the polygon centroid) for each response. The points are clearer to see at a high level and are a better choice for pop-ups.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I have two copies of the polygon layer (public view version) in the webmap and I'm using the 'Color and Size' style option to make one of the layers 'appear' as points. The issue with this is that I can't utilise features specific to point layers such as clustering.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead I would like to generate a genuine point layer which references all the data from the polygons, and uses the centroid as the point co-ordinates. I know this is something that can be done manually from the layer, but I'd like the points to continue to populate as responses are submitted and new polygons appear.&lt;/P&gt;&lt;P&gt;Is there a mechanism by which this can be done? The only thing I can think of would be utilising a notebook which perhaps is triggered by a survey response, but I'm not familiar with notebooks and I'm unsure about how to go about this and if the credit usage will be reasonable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 12:47:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125372#M43330</guid>
      <dc:creator>KatieSelf</dc:creator>
      <dc:date>2021-12-13T12:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125408#M43333</link>
      <description>&lt;P&gt;Create a new point feature class:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;name: PolygonCentroids&lt;/LI&gt;&lt;LI&gt;add GlobalID&lt;/LI&gt;&lt;LI&gt;add Field: PolygonGUID, type GUID&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Create a relationship class between the polygon feature class and PolygonCentroids:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;name: RsPolygonCentroids&lt;/LI&gt;&lt;LI&gt;key fields: Polygons.GlobalID, PolygonCentroids.PolygonGUID&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Create an attribute rule for your polygon feature class:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on polygon feature class
// field: empty
// triggers: insert, update, delete

// this object will be returned to edit the related point fc
var edit_points = {"className": "PolygonCentroids", "adds": [], "updates": [], "deletes": []}

var mode = $editcontext.editType
var poly_guid = $feature.GlobalID
var p_geometry = Centroid($feature)
var p_attributes = {"PolygonGUID": poly_guid}

if(mode == "INSERT") {
  // if a polygon is inserted, insert a new point
  Push(edit_points.adds, {"geometry": p_geometry, "attributes": p_attributes})
} else {
  // find the related point(s)
  var related_points = FeatureSetByRelationshipName($feature, "RsPolygonCentroids")
  for(var p in related_points) {
    if(mode == "UPDATE") {
      // update geometry
      Push(edit_points.updates, {"globalID": p.GlobalID, "geometry": p_geometry})
    }
    if(mode == "DELETE") {
      // delete point
      Push(edit_points.deletes, {"globalID": p.GlobalID})
    }
  }
}

// apply the edits
return {"edits": [edit_points]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The names are up to you, of course, but you have to change them in the script accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give you an automatically updated point feature class with the polygon centroids and the GlobalID of the respective polygons. To get the polygon attributes in the point popup, create an Arcade expression for each attribute you want to show, you can show the results in the popup's attribute table as usual.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var related_polygons = FeatureSetByRelationshipName($feature, "RsPolygonCentroids")
if(Count(related_polygons) &amp;gt; 0) {
  return First(related_polygons).Attribute
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 14:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125408#M43333</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-13T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125876#M43358</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thank you for you answer, I haven't used relation classes before so this looks perfect. I'm afraid I'm having a bit of trouble trying to implement. I tried to set relationship class in ArcPro (referencing the layers hosted on AGOL) but got the following error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KatieSelf_0-1639494803121.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29660iE7C1FD695C9CBA35/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KatieSelf_0-1639494803121.png" alt="KatieSelf_0-1639494803121.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this directly on AGOL that I'm missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 15:15:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1125876#M43358</guid>
      <dc:creator>KatieSelf</dc:creator>
      <dc:date>2021-12-14T15:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1126209#M43387</link>
      <description>&lt;P&gt;Ah, I overlooked the AGOL tag...&lt;/P&gt;&lt;P&gt;You can't create a relationship class between AGOL layers. You can only create them between tables/feature classes in geodatabases and then publish the tables. Same with attribute rules.&lt;/P&gt;&lt;P&gt;Honestly, I'm not sure if my approach works in AGOL at all, never used it. I know it works when you publish the layers to Portal and consume them in a web app.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 10:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1126209#M43387</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-15T10:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1126287#M43395</link>
      <description>&lt;P&gt;Hi Johannes - thanks for the code anyway. Definitely looks helpful for replicating what I want outside of AGOL. It's a shame that relationship classes aren't supported on AGOL.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 16:22:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1126287#M43395</guid>
      <dc:creator>KatieSelf</dc:creator>
      <dc:date>2021-12-15T16:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1390427#M57835</link>
      <description>&lt;P&gt;I am currently trying to implement an attribute rule on a polygon feature class (AG_PL) to add, update or delete a point feature (AG_PT) geometry and populate 'PolygonGUID' field in AG_PT with AG_PL's GlobalID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;AG_PL and AG_PT are in composite relationship called (AG_PL_AG_PT).&lt;/P&gt;&lt;P&gt;When I test creating a new polygon or moving an existing polygon or deleting an existing polygon I receive this message below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've reviewed the arcade expression several times but am unable to identify the Undefined Keyword.&amp;nbsp; Any help on this would be much appreciated.&amp;nbsp; Thanks!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Failed to create 4.
Undefined keyword is used in the dictionary return script. [
Rule name: Poly,
Triggering event: Insert,
Class name: AG_PL,
GlobalID: {D7E577D7-9F8F-4099-AE23-9B5DBCDD3EC3}]Undefined keyword is used in the dictionary return script. [edits]&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on polygon feature class
// field: empty
// triggers: insert, update, delete
// Push(edit_points.adds, {"geometry": p_geometry, "attributes": p_attributes})
// this object will be returned to edit the related point fc
var edit_points = {"className": "AG_PT", "adds": [], "updates": [], "deletes": []}

var mode = $editcontext.editType
var poly_guid = $feature.GlobalID
var p_geometry = Centroid($feature)
var p_attributes = {'PolygonGUID': poly_guid}


if (mode == "INSERT") {
  // if a polygon is inserted, insert a new point
  Push(edit_points.adds, {"geometry": p_geometry, "attributes": p_attributes})
} 


else {
  // find the related point(s)
  var related_points = FeatureSetByRelationshipName($feature, 'AG_PL_AG_PT')
  for(var p in related_points) {
    if(mode == "UPDATE") {
      // update geometry
      Push(edit_points.updates, {'globalID': p.GlobalID, 'geometry': p_geometry})
    }
    if(mode == "DELETE") {
      // delete point
      Push(edit_points.deletes, {'globalID': p.GlobalID})
    }
  }
}

// apply the edits
return {"edits": [edit_points]}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 04 Mar 2024 15:34:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1390427#M57835</guid>
      <dc:creator>TerrolPalmer6</dc:creator>
      <dc:date>2024-03-04T15:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1398021#M58201</link>
      <description>&lt;P&gt;Looks like that error is caused by Line 36&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;return {"edits": [edit_points]}&lt;/LI-CODE&gt;&lt;P&gt;should be "edit"&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;return {"edit": [edit_points]}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 18:12:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1398021#M58201</guid>
      <dc:creator>Amarz</dc:creator>
      <dc:date>2024-03-19T18:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Auto-generating and updating a centroid point layer from a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1398022#M58202</link>
      <description>&lt;P&gt;Looks like that error is caused by Line 36&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;return {"edits": [edit_points]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;should be "edit"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;return {"edit": [edit_points]}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 18:13:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/auto-generating-and-updating-a-centroid-point/m-p/1398022#M58202</guid>
      <dc:creator>Amarz</dc:creator>
      <dc:date>2024-03-19T18:13:16Z</dc:date>
    </item>
  </channel>
</rss>

