<?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: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class. in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1066302#M138</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp; Thank you for the additional information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I got point 1 &amp;amp; 2 partially working&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":birthday_cake:"&gt;🎂&lt;/span&gt; &amp;nbsp;But there are still a lot of unanswered questions. For example,&amp;nbsp;why do they use an empty field called "Field" as a central point for the Attribute Rule? Is this necessary? And why return it widhout an action?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a "definition query ", am I on the right track with this approach?&amp;nbsp; And how can I rewrite "A" to "C" and "B" to "D" at this point?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//If value of field X is "A" or "B" proceed, else do nothing (Insert or Update). 
var IsCorrecteWaarde =($feature).X == "A" or ($feature).X == "B" 

else {
return
}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//----------------------------------------------------
//Create a centerpoint of the given polygon. Z=Zero, because of the Z-awareness of the FC. 
var centroidFeatureR****e = Point({ 'x': centroid($feature).x, 'y': centroid($feature).y, 'z': 0, 'spatialReference':{'wkid':28992} })
//----------------------------------------------------

return {
       //In the example they used a empty field! So do we! I do'nt really understand why (yet).
      "result": $feature.field,
       //this keyword indicates an edit that need to happen, its an array since we can make many edits [example text]
       "edit": [  
           {  
               //The Point-FC (g**m.i***************t), what is the derivative of the source (g**m.r****e). 
               "className" : "g**m.i***************t", 
                  
               //all fields &amp;amp; Geometry that we want to include in the new Featureclass. 
               "adds" : [
                      {
                            //the attribute of the feature we want to add, 
                            // R****ID &amp;amp; the GlobalID will work as a 'offline relationshipclass'
                            "attributes":  
                             {
                                   "R****ID": $feature.globalid, 
                                   //All the another fields I deleted because of the AVG-law. 
                               }, 

                            //The geometry will be the variable 'centroidFeatureR****e' we determined earlier. 
                            "geometry": centroidFeatureR****e

                      }
             ]
            }
     ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you in advanced&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jun 2021 11:54:08 GMT</pubDate>
    <dc:creator>Manniej</dc:creator>
    <dc:date>2021-06-09T11:54:08Z</dc:date>
    <item>
      <title>Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1065883#M136</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short: I am working on a Calculation Attribute Rule what should should 2 things:&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;To create a centerpoint from polygon feature;&lt;/LI&gt;&lt;LI&gt;To update all the available fields in a second featureclass when inserted or updatet.&lt;UL&gt;&lt;LI&gt;The original is a polygon, the second fc is a point featureclass. &amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I did find and tried to use the following &lt;A title="advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules" href="https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules/" target="_self"&gt;blog.&amp;nbsp;&lt;/A&gt;But unfortunately this turned out not to be enough to get it working with my current level of knowledge.&amp;nbsp;&lt;/P&gt;&lt;P&gt;ArcGis Pro version:&amp;nbsp; 2.7.1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me out and help me out to create this beautiful product?&amp;nbsp; &amp;nbsp;(Thank you in advanced).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 08:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1065883#M136</guid>
      <dc:creator>Manniej</dc:creator>
      <dc:date>2021-06-08T08:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1065895#M137</link>
      <description>&lt;P&gt;Please post the code you already have and tell us what problems you have with it (erro messages etc).&lt;/P&gt;&lt;P&gt;To post code: expand the toolbar in the comment box, insert a code sample, chose Javascript as language.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1623143269177.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15384i88EE82B88C5AEF3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1623143269177.png" alt="JohannesLindner_0-1623143269177.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1623143284020.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15385i4D75C10C352E3D4F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1623143284020.png" alt="JohannesLindner_1-1623143284020.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 09:08:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1065895#M137</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-08T09:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1066302#M138</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp; Thank you for the additional information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I got point 1 &amp;amp; 2 partially working&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":birthday_cake:"&gt;🎂&lt;/span&gt; &amp;nbsp;But there are still a lot of unanswered questions. For example,&amp;nbsp;why do they use an empty field called "Field" as a central point for the Attribute Rule? Is this necessary? And why return it widhout an action?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a "definition query ", am I on the right track with this approach?&amp;nbsp; And how can I rewrite "A" to "C" and "B" to "D" at this point?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//If value of field X is "A" or "B" proceed, else do nothing (Insert or Update). 
var IsCorrecteWaarde =($feature).X == "A" or ($feature).X == "B" 

else {
return
}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//----------------------------------------------------
//Create a centerpoint of the given polygon. Z=Zero, because of the Z-awareness of the FC. 
var centroidFeatureR****e = Point({ 'x': centroid($feature).x, 'y': centroid($feature).y, 'z': 0, 'spatialReference':{'wkid':28992} })
//----------------------------------------------------

return {
       //In the example they used a empty field! So do we! I do'nt really understand why (yet).
      "result": $feature.field,
       //this keyword indicates an edit that need to happen, its an array since we can make many edits [example text]
       "edit": [  
           {  
               //The Point-FC (g**m.i***************t), what is the derivative of the source (g**m.r****e). 
               "className" : "g**m.i***************t", 
                  
               //all fields &amp;amp; Geometry that we want to include in the new Featureclass. 
               "adds" : [
                      {
                            //the attribute of the feature we want to add, 
                            // R****ID &amp;amp; the GlobalID will work as a 'offline relationshipclass'
                            "attributes":  
                             {
                                   "R****ID": $feature.globalid, 
                                   //All the another fields I deleted because of the AVG-law. 
                               }, 

                            //The geometry will be the variable 'centroidFeatureR****e' we determined earlier. 
                            "geometry": centroidFeatureR****e

                      }
             ]
            }
     ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you in advanced&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 11:54:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1066302#M138</guid>
      <dc:creator>Manniej</dc:creator>
      <dc:date>2021-06-09T11:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1066325#M139</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;why do they use an empty field called "Field"&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Because calculation rules expect a field to be calculated.&lt;/P&gt;&lt;P&gt;A very simple form of a calculation rule would be&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// calculate field C as sum of fields A and B
var c = $feature.a + $feature.b
return c&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;In this simple form, you don't return a dictionary like in the blog post you linked, but a simple value. In the rule creation window you sspecify the field this value is stored in.&lt;/P&gt;&lt;P&gt;The advanced attribute rules enhance this behavior, so that by editing one table, you can do stuff in other tables. The basic behavior stays the same: the rule still wants to know what value to return and in which field to store the returned value.&lt;/P&gt;&lt;P&gt;In the blog post, they don't care about calculating attributes for the point, they just want to automatically create a polygon around the point (the inverse of what you are doing). But because the rule expects a return value and a field, they just use an empty field and return the value that is already there. You don't have to create an extra field for that. Just take a field that is already in your polygon FC (you have to be able to edit it, so not things like ObjectID or GlobalID) and return its value. By returning the value that is already stored in the field, you ensure that nothing is actually changed.&lt;/P&gt;&lt;P&gt;For eample, my calculation rules for primary keys look something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation rule for a primary key field
// Field: BauwerkID
// Triggers: Insert, Update

// check if the field is empty
if(IsEmpty($feature.BauwerkID)) {
  // yes -&amp;gt; return a new value
  return NextSequenceValue("SequenceBauwerkID")
}
// no -&amp;gt; return the field's value (change nothing)
return $feature.BauwerkID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;I need to add a "definition query ", am I on the right track with this approach?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;//If value of field X is "A" or "B" proceed, else do nothing (Insert or Update).
if($feature.X == "A" || $feature.X == "B") {
  // do stuff
}
else {
  return $feature.Field  // return the value that is already stored in your field. In this case, no point feature will be created.
}


// Personally, I find code easier to read if you do it the other way around:
if($feature.X != "A" &amp;amp;&amp;amp; $feature.X != "B") {
  return $feature.Field
}
// Do stuff&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;And how can I rewrite "A" to "C" and "B" to "D" at this point?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm not sure I understand you correctly: You have a polygon feature with X = "A", so you want to create a point feature and then change X to "C"?&lt;/P&gt;&lt;P&gt;In this case, your field for the calculation rule would be X.&lt;/P&gt;&lt;LI-CODE lang="java"&gt;// if field X is not "A" or "B", do nothing
if($feature.X != "A" &amp;amp;&amp;amp; $feature.X !="B") {
  return $feature.X
}

// else get the new value for X
var new_x = IIF($feature.X == "A", "C", "D")  // $feature.X can only be "A" or "B" at this point (else we would have returned above)
// get the centroid
var centroid = ...

// return
return {
  "result": new_x,
  "edit": ...
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Jun 2021 12:51:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1066325#M139</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-09T12:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067234#M140</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;,&amp;nbsp;thank you once again for the explaination,&amp;nbsp;this is much appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a little clarification on the last part, I need to rewrite a value after a point is created and we did the check.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;For example&lt;/U&gt;: In the Polygon FC&lt;EM&gt;: $feature.PolygonFC_type == "Liftschacht"&amp;nbsp; &amp;nbsp;&lt;/EM&gt;it should be&lt;EM&gt; $feature.PointFC_Type == "Lift" &lt;/EM&gt;in the destinated pointFC.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 06:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067234#M140</guid>
      <dc:creator>Manniej</dc:creator>
      <dc:date>2021-06-11T06:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067236#M141</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// get point type from polygon type
var polygon_type = $feature.PolygonFC_type
var point_type = ""
if(polygon_type == "Liftschacht") { point_type = "Lift" }
if(polygon_type == "ABC") { point_type = "DEF" }
if(polygon_type == "UVW") { point_type = "XYZ" }

// centroid

// return point_type as attribute in the newly created point
return {
  "result": $feature.field,
  "edit": [
    {   
      "className" : "g**m.i***************t", 
      "adds" : [
        {
          "attributes": {
            "R****ID": $feature.globalid,
            "PointFC_Type": point_type 
            // other fields
          },
          "geometry": centroidFeatureR****e
        }
      ]
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 07:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067236#M141</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-11T07:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067298#M142</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;for your time and energy, you helped me a lot, &amp;nbsp;It is working!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still need to learn a lot!&amp;nbsp; But I see the potentional of attribute rules!&amp;nbsp; Mercy for this insight!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 11:28:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067298#M142</guid>
      <dc:creator>Manniej</dc:creator>
      <dc:date>2021-06-11T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a centerpoint from a polygon Feature class and add the attributes to another Feature Class.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067306#M143</link>
      <description>&lt;P&gt;Glad to help!&lt;/P&gt;&lt;P&gt;Yeah, attribute rules (and Arcade in other instances, like popups, field calculation, advanced symbology and labels) can be pretty powerful, and they're still adding stuff to it. But you have to learn the language, it certainly helps if you have experience in other programming/script languages.&lt;/P&gt;&lt;P&gt;You kinda jumped in at the deep end, here. There's a reason the blog is titled "Advanced Attribute Rules" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case you haven't found it yet: The &lt;A href="https://developers.arcgis.com/arcade/guide/" target="_blank" rel="noopener"&gt;Arcace Guide&lt;/A&gt; and the &lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank" rel="noopener"&gt;Function Reference&lt;/A&gt; are great resources.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 11:48:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-a-centerpoint-from-a-polygon-feature-class/m-p/1067306#M143</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-11T11:48:42Z</dc:date>
    </item>
  </channel>
</rss>

