<?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: Arcade Nearest Vertex / Nearest Coordinate Functions in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1317646#M53864</link>
    <description>&lt;P&gt;The coordinates suggest that you are using a geographic coordinate system. For distance measurements, you should use a projected coordinate system.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2023 20:04:07 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-08-10T20:04:07Z</dc:date>
    <item>
      <title>Arcade Nearest Vertex / Nearest Coordinate Functions</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316106#M53776</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I want to test the functions mentioned above (Nearest Vertex / Nearest Coordinate) however I'm not having much luck with what should be a fairly basic bit of Arcade ...&lt;/P&gt;&lt;P&gt;The aim was to click on a point on the map and it would run the following pop-up expression to test against the first candidate from a nearby polygonal dataset:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var featurePt = $feature
var featurePly = FeatureSetByPortalItem(
  Portal('https://www.arcgis.com'),
  '...ItemIDHere...', // A valid Item ID would be here...
  0,
  ['*'],
  true
);

var nearestPly = First(Intersects(featurePly, Buffer(featurePt, 10, "kilometers")));

var result = NearestVertex(nearestPly,featurePt)

return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This however returns the following error:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Test execution error: Execution error - Invalid parameter. Verify test data.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I debug it line-by-line, everything works until the NearestVertex line. From what I can see in the guidance I have all the parameters. Hit the same issue with NearestCoordinate function.&lt;/P&gt;&lt;P&gt;Can anyone advise what I'm doing wrong/what's missing?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 16:58:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316106#M53776</guid>
      <dc:creator>TimF</dc:creator>
      <dc:date>2023-08-07T16:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Nearest Vertex / Nearest Coordinate Functions</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316575#M53804</link>
      <description>&lt;P&gt;Hmm, I couldn't reproduce the error.&lt;/P&gt;&lt;P&gt;But you need a null check after line 10:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(nearestPly == null) { return "No polygon found" }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And right now you're returning a dictionary with the keys "coordinate" and "distance". You probably want to return one of those values instead.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 18:41:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316575#M53804</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-08-08T18:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Nearest Vertex / Nearest Coordinate Functions</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316803#M53822</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thanks for the response. Good shout on the null check and specific dictionary response.&lt;/P&gt;&lt;P&gt;I did get these functions to work on different test data i.e., a new layer with a single point, comparing to another new layer with a single polygon. I'm not sure what was wrong with my hosted layers... but this at least allows me check the accuracy of the outputs.&lt;/P&gt;&lt;P&gt;Do you happen to know if the distance returned is source-&amp;gt;target-&amp;gt;source (i.e., double-counting)?&lt;/P&gt;&lt;P&gt;I found the Nearest Coordinate distance, when divided by two, returned the closest distance to the true distance calculated in Pro (and shown with the Measure tool). However I wasn't sure if that was a rule-of-thumb I could rely on....&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TimF_0-1691581059484.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/77642iEAB826FE02C1EF21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TimF_0-1691581059484.png" alt="TimF_0-1691581059484.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TimF_1-1691581072258.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/77643i8DA16DA3C2F0D2F1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TimF_1-1691581072258.png" alt="TimF_1-1691581072258.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 11:42:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1316803#M53822</guid>
      <dc:creator>TimF</dc:creator>
      <dc:date>2023-08-09T11:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Nearest Vertex / Nearest Coordinate Functions</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1317646#M53864</link>
      <description>&lt;P&gt;The coordinates suggest that you are using a geographic coordinate system. For distance measurements, you should use a projected coordinate system.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 20:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-nearest-vertex-nearest-coordinate-functions/m-p/1317646#M53864</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-08-10T20:04:07Z</dc:date>
    </item>
  </channel>
</rss>

