<?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: Update point geometry based on polygons centroid in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197572#M495</link>
    <description>&lt;P&gt;So, that means that there's nothing in the intersection.&lt;/P&gt;&lt;P&gt;Instead of checking &lt;STRONG&gt;IsEmpty&lt;/STRONG&gt; on the centroid, check first on the &lt;STRONG&gt;parcels &lt;/STRONG&gt;FeatureSet.&lt;/P&gt;&lt;PRE&gt;if(Count(parcels) &amp;lt; 1){&lt;BR /&gt;    Console('No intersecting parcels')&lt;BR /&gt;    // return some default message&lt;BR /&gt;} else {&lt;BR /&gt;    parcel = First(parcels)&lt;BR /&gt;    var parcelCentroid = Centroid(parcel)&lt;BR /&gt;    ... etc&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jul 2022 19:02:56 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-07-29T19:02:56Z</dc:date>
    <item>
      <title>Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197523#M492</link>
      <description>&lt;P&gt;I've got a strange one for you folks. Working with some address points and parcel polygons, is it possible to get the x and y geometry from a centroid of an intersecting polygon?&lt;/P&gt;&lt;P&gt;I followed this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-script-expression.htm#anchor5" target="_self" rel="nofollow noopener noreferrer"&gt;documentation&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and the way the author's script works great when replicating the author's scenario. Yet when I try to get the centroid of a polygon I get an error 'Expected convertable to geometry'.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Basically, I'm trying to update the geometry of a point on intersect based on the centroid geometry of the intersecting polygon&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//This calculation attribute rule is added to the shape field of a point feature $feature
var parcels = Intersects(FeatureSetByName($datastore, "Parcel", ["*"], true), $feature)
var parcelCentriod = Centroid(parcels)
if (!IsEmpty(parcelCentriod)) {
    var x0 = Geometry(parcelCentriod).x
    var y0 = Geometry(parcelCentriod).y
    var addressPoint = Point({
        "x": x0,
        "y": y0,
        "z": 0,
        "spatialReference": Geometry(parcelCentriod).spatialReference
    });
    return addressPoint
}
return{
    "errorMessage": Text('Something Went Wrong')
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 17:56:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197523#M492</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-07-29T17:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197529#M493</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Intersects &lt;/STRONG&gt;returns a FeatureSet. &lt;STRONG&gt;Centroid&lt;/STRONG&gt; requires a Feature.&lt;/P&gt;&lt;P&gt;Add something like&lt;/P&gt;&lt;PRE&gt;var parcel = First(parcels)&lt;/PRE&gt;&lt;P&gt;between lines 2 and 3, then have your&amp;nbsp;&lt;STRONG&gt;Centroid&amp;nbsp;&lt;/STRONG&gt;function use&amp;nbsp;&lt;STRONG&gt;parcel&lt;/STRONG&gt; as its input.&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 18:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197529#M493</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-07-29T18:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197569#M494</link>
      <description>&lt;P&gt;Josh thanks for the advice. I tried that in the past. Here is the new error....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_0-1659121057582.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47278i8924AED52AADC7D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_0-1659121057582.png" alt="JS_Esri_0-1659121057582.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 18:58:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197569#M494</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-07-29T18:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197572#M495</link>
      <description>&lt;P&gt;So, that means that there's nothing in the intersection.&lt;/P&gt;&lt;P&gt;Instead of checking &lt;STRONG&gt;IsEmpty&lt;/STRONG&gt; on the centroid, check first on the &lt;STRONG&gt;parcels &lt;/STRONG&gt;FeatureSet.&lt;/P&gt;&lt;PRE&gt;if(Count(parcels) &amp;lt; 1){&lt;BR /&gt;    Console('No intersecting parcels')&lt;BR /&gt;    // return some default message&lt;BR /&gt;} else {&lt;BR /&gt;    parcel = First(parcels)&lt;BR /&gt;    var parcelCentroid = Centroid(parcel)&lt;BR /&gt;    ... etc&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 19:02:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197572#M495</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-07-29T19:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197611#M496</link>
      <description>&lt;P&gt;The same error occurs just in the else statement. So it sees the intersection,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_0-1659126005126.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47287i9260B7AEC51CE3BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_0-1659126005126.png" alt="JS_Esri_0-1659126005126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Some reason just having an issue with getting the centroid geometry still. Not sure this is even possible.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for your help though!!!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 20:27:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1197611#M496</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-07-29T20:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Update point geometry based on polygons centroid</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1198873#M502</link>
      <description>&lt;P&gt;Can you post a sample dataset with the rule?&lt;/P&gt;&lt;P&gt;Couple things:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; - In this case, I would not call Count.&amp;nbsp; Count can be expensive, as it makes a query to the FS.&amp;nbsp; Best to just call First or loop over the FS and exit on the first record&lt;/P&gt;&lt;P&gt;&amp;nbsp; - I do not like reusing the variable parcel to be the FeatureSet and the Feature.&amp;nbsp; Change the first item to var parcelFS&lt;/P&gt;&lt;P&gt;&amp;nbsp; - If you right click in the expression, you can turn on line numbers.&amp;nbsp; Will help identify which line has the error&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 10:15:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-point-geometry-based-on-polygons-centroid/m-p/1198873#M502</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-03T10:15:42Z</dc:date>
    </item>
  </channel>
</rss>

