<?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: Finding furthest distances between two sets of points in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343812#M26937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think part of what is confusing people is semantics, particularly the use of the word "furthest."&amp;nbsp; Assuming no two construction sites are exactly the same distance from a waste facility, you will only have one construction site that is furthest away.&amp;nbsp; If by furthest you mean far, then a definition of what is far and what is close would be helpful.&amp;nbsp; Or, are you looking to simply determine the distance from each construction site to each waste facility?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Mar 2015 19:16:37 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-03-18T19:16:37Z</dc:date>
    <item>
      <title>Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343806#M26931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two sets of points- list A and list B. I need to efficiently select the points from list B that are furthest from points in list A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason Near Table isn't working out is because of the number of (redundant) records showing the distance of each point on list B to every single point on list A. That's 9000 entries (A) x 500 entries (B) for a total of 4,500,000 records generated by the near table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to end up with an ordered list of points from list B that are furthest away from any points on list A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems like a simple thing to ask but not so simple to do.&lt;/P&gt;&lt;P&gt;How can I approach this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 17:14:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343806#M26931</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T17:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343807#M26932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some questions to help clarify this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Is the issue technical - i.e. the analysis bogs down/software crashes due to the large amount of records?&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Is the issue that their are many resulting Near records and uncertainty on how to query these results down to get the final answer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris Donohue, GISP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 17:29:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343807#M26932</guid>
      <dc:creator>ChrisDonohue__GISP</dc:creator>
      <dc:date>2015-03-18T17:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343808#M26933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. No technical issue. I did an experiment with a smaller data set. The application produces the table after some time. I really don't mind letting it run overnight to get 4.5 million records if that's what needs to be done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Yes, there are way too many records produced. It's not the amount of them but their redundancy. Each point in B is matched to all points in A, multiplying the amount of records. I suspect that there is a way to leave just the highest-distance records in the near table for each point from the initial list of points B.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 17:49:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343808#M26933</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T17:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343809#M26934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It can be done with Python, but I don't know if I understand the end result you are looking for.&amp;nbsp; Your way of describing what you want is very confusing.&amp;nbsp; Here is what I think you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. For any given point in A (shape) find the distance to the closest point in B along with the point B ObjectID (Attributes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Sort the points in A by the distance to B in descending order so that the furthest distance point in A is at the top of the list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that correct?&amp;nbsp; Or perhaps rule 1 should be : For any given point in A find the distance to the furthest point in B along with the Point B ObjectID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This assumes you want the point shape from A and just the attributes from B.&amp;nbsp; But your description could mean that you want the to keep the point shape in B and attribute it with the distance and ObjectID of a point in A.&amp;nbsp; Or do you want a table with the coordinates of both points that meet your rule 1 so that you could make an XY point layer based on either the location in A or the location in B?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically at the end should there be 9000 records (one for each point in A) or 500 records (one for each point in B).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 18:00:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343809#M26934</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-03-18T18:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343810#M26935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Richard, I think you got it right in your first description.&lt;/P&gt;&lt;P&gt;I must find the closest distances between points on separate lists, then sort them so the furthest distance is at the top of the list as you've said.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a way to illustrate the problem.&lt;/P&gt;&lt;P&gt;Suppose I have a list of potential construction sites and a list of toxic waste facilities. I want to list the construction sites that are furthest away from all waste facilities. I'm showing each site with a point, not a polygon. &lt;/P&gt;&lt;P&gt;So I want to end up with the theoretical 500 sites sorted by distance to the nearest 9000 hazards, for a total of 500 records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 18:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343810#M26935</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T18:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343811#M26936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure I completely understand, but to get the nearest distance between construction and toxic sites, use &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Near/00080000001q000000/"&gt;Near &lt;/A&gt;(outputs only nearest features) rather than &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Generate_Near_Table/00080000001n000000/"&gt;Generate Near Table&lt;/A&gt; (potentially outputs all combinations). Then, sort the feature class by near distance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 18:40:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343811#M26936</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-18T18:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343812#M26937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think part of what is confusing people is semantics, particularly the use of the word "furthest."&amp;nbsp; Assuming no two construction sites are exactly the same distance from a waste facility, you will only have one construction site that is furthest away.&amp;nbsp; If by furthest you mean far, then a definition of what is far and what is close would be helpful.&amp;nbsp; Or, are you looking to simply determine the distance from each construction site to each waste facility?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343812#M26937</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-18T19:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343813#M26938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is it. Please let try this and get back to you. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343813#M26938</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T19:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343814#M26939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you after nearest or farthest points?&amp;nbsp; You say "furthest" a lot but then you also say "closest" at one point.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:38:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343814#M26939</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-18T19:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343815#M26940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My interpretation is that she's looking for "the construction site farthest from the nearest toxic waste facility," which makes sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343815#M26940</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-18T19:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343816#M26941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you everyone for all your help. &lt;/P&gt;&lt;P&gt;Since there is a limited number sites and facilities, we can order all the sites by distance from their closest waste facilities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In practice you would not really have identical distances between points. &lt;/P&gt;&lt;P&gt;So at the very top of the list you would have one construction site that you could say is further from all environmental hazards than any other site you have on the list, right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:42:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343816#M26941</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T19:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343817#M26942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I get it, you want to find the nearest hazard site to each construction site, and then rank/order all the construction sites in descending order of that value.&amp;nbsp; So, the construction site at the top has the largest minimum distance to a hazard site.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 19:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343817#M26942</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-18T19:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343818#M26943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's it.&lt;/P&gt;&lt;P&gt;I realize that my original question may have been a bit off.&lt;/P&gt;&lt;P&gt;I was originally using Near Table and was trying to efficiently get rid of the non-relevant records. (Non-relevant meaning those that do not help identify points with the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;largest minimum distance to a hazard)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I did't realize I could do this with just the Near tool as Darren has suggested. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 20:04:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343818#M26943</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T20:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343819#M26944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've done something similar and the Near table worked for me. When I was doing this, I also found it frustrating that the Near table would only show the ObjectID of the features, requiring additional joins to actually see what features the OIDs were for. I created this Python script that will create a Near table with a key field of your choice in the output. I haven't tested it much but maybe you can get some use out of it. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set local variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceGDB = r"C:\temp\mytempsource.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outputGDB = r"C:\temp\mytempoutput.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; ## IN and NEAR features can be the same
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc = "FeatureClassIn_Name"
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_keyfield_name = "KeyField_Name"
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_keyfield_type = "Long"
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_path = os.path.join(sourceGDB, in_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc = "FeatureClassNear_Name"
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_keyfield_name = "KeyField_Name"
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_keyfield_type = "Long"
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_path = os.path.join(sourceGDB, near_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; search_radius = "25 Feet"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create near table and make as TableView
&amp;nbsp;&amp;nbsp;&amp;nbsp; neartable_inmem = os.path.join("in_memory", "neartable_inmem")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GenerateNearTable_analysis(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_path,&amp;nbsp; ## in_features
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_path,&amp;nbsp; ## near_features
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; neartable_inmem,&amp;nbsp; ## out_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search_radius,&amp;nbsp; ## search_radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "NO_LOCATION",&amp;nbsp; ## location
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "NO_ANGLE",&amp;nbsp; ## angle
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "ALL",&amp;nbsp; ## closest
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "0",&amp;nbsp; ## closest_count
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "PLANAR"&amp;nbsp; ## method
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeTableView_management(neartable_inmem, "neartable_view")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Near table view created"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add new IN and NEAR key fields to near table
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_kf = "IN_{}".format(in_fc_keyfield_name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_kf,&amp;nbsp; ## field_name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_keyfield_type,&amp;nbsp; ## field_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_kf = "NEAR_{}".format(near_fc_keyfield_name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_kf,&amp;nbsp; ## field_name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_keyfield_type,&amp;nbsp; ## field_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Key fields added"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Join and calc IN key field
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddJoin_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_layer_or_view
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "IN_FID",&amp;nbsp; ## in_field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_fc_path,&amp;nbsp; ## join_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "OBJECTID",&amp;nbsp; ## join_field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "KEEP_COMMON"&amp;nbsp; ## join_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_kf,&amp;nbsp; ## field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "!{}!".format(in_fc_keyfield_name),&amp;nbsp; ## expression
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "PYTHON_9.3"&amp;nbsp; ## expression_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RemoveJoin_management("neartable_view")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{} field populated".format(in_kf)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Join and calc NEAR key field
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddJoin_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_layer_or_view
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "NEAR_FID",&amp;nbsp; ## in_field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_fc_path,&amp;nbsp; ## join_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "OBJECTID",&amp;nbsp; ## join_field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "KEEP_COMMON"&amp;nbsp; ## join_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_kf,&amp;nbsp; ## field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "!{}!".format(near_fc_keyfield_name),&amp;nbsp; ## expression
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "PYTHON_9.3"&amp;nbsp; ## expression_type
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RemoveJoin_management("neartable_view")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{} field populated".format(near_kf)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export final near table
&amp;nbsp;&amp;nbsp;&amp;nbsp; kf_near_table = "{}_NEAR".format(in_fc.replace('.', '_'))&amp;nbsp; ## Replace any dot with underscore and add _NEAR suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; kf_near_table_path = os.path.join(outputGDB, kf_near_table)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRows_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "neartable_view",&amp;nbsp; ## in_rows
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kf_near_table_path&amp;nbsp; ## out_table
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Final near table output at {}".format(kf_near_table_path)

except Exception as err:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print err
&amp;nbsp;&amp;nbsp;&amp;nbsp; ## If there was an ArcPy error, write all of the messages returned by the last tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.GetMessages(2):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

finally:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("in_memory")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ClearWorkspaceCache_management()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343819#M26944</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T16:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343820#M26945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good god. I have no experience with Python yet, so I'm going to take this down and chew on it later ^^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 22:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343820#M26945</guid>
      <dc:creator>MarleneSanchez</dc:creator>
      <dc:date>2015-03-18T22:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343821#M26946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haha! Well, you did post in the Python section so I thought I would go for it. It's not as complicated as it looks.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create Near table&lt;/LI&gt;&lt;LI&gt;Add two new fields for in and near key fields&lt;/LI&gt;&lt;LI&gt;Join the original feature classes to field calc the in and near key field values&lt;/LI&gt;&lt;LI&gt;Export final near table&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 22:51:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343821#M26946</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-18T22:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343822#M26947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you were interested in the farthest instead of nearest, then you would have to use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/point-distance.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Point Distance &lt;/A&gt;or &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/generate-near-table.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Generate Near Table&lt;/A&gt; in your workflow, unless you wanted to role your own NumPy-based function.&amp;nbsp; When working with data sets in the tens of thousands, which much from a practical stand point, I have found the Point Distance tool to be very slow and sometimes Generate Near Table fails with unspecified errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For situations where I want farthest points or quicker outputs similar to Point Distance, I have roled my own NumPy-based functions.&amp;nbsp; For example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def stat_point(in_features, other_features, stat='MINIMUM'):
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; import numpy
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; stats = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MINIMUM': {'FID': 'MIN_FID',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'DIST': 'MIN_DIST',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'INDEX': lambda x: 0},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MAXIMUM': {'FID': 'MAX_FID',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'DIST': 'MAX_DIST',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'INDEX': lambda x: x - 1},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MEDIAN_HIGH': {'FID': 'MEDH_FID',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'DIST': 'MEDH_DIST',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'INDEX': lambda x: x / 2},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MEDIAN_LOW': {'FID': 'MEDL_FID',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'DIST': 'MEDL_DIST',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'INDEX': lambda x: x / 2 - 1 if x % 2 == 0 else x / 2 }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(in_features)
&amp;nbsp;&amp;nbsp;&amp;nbsp; SR = desc.spatialReference
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(other_features)
&amp;nbsp;&amp;nbsp;&amp;nbsp; OID_name_other = desc.OIDFieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; shape_name_other = desc.ShapeFieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; narr_other = arcpy.da.FeatureClassToNumPyArray(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; other_features,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OID_name_other, desc.ShapeFieldName],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spatial_reference = SR
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; xy_other = narr_other[shape_name_other]
&amp;nbsp;&amp;nbsp;&amp;nbsp; idx = stats[stat]['INDEX'](numpy.shape(xy_other)[0])
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(in_features, stats[stat]['FID'], 'LONG')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(in_features, stats[stat]['DIST'], 'DOUBLE')
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_features,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["&lt;A href="mailto:SHAPE@XY" rel="nofollow noopener noreferrer" target="_blank"&gt;SHAPE@XY&lt;/A&gt;", stats[stat]['FID'], stats[stat]['DIST']]
&amp;nbsp;&amp;nbsp;&amp;nbsp; ) as cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for xy, FID, DIST in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xy_in = numpy.array(xy)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d0 = numpy.subtract.outer(xy_in[0], xy_other[:,0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d1 = numpy.subtract.outer(xy_in[1], xy_other[:,1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dist = numpy.hypot(d0, d1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = dist.argsort()[idx]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FID = narr_other[OID_name_other]&lt;I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DIST = dist&lt;I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow([xy, FID, DIST])&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When used with &lt;SPAN style="font-family: courier new,courier;"&gt;"MINIMUM",&lt;/SPAN&gt; the &lt;SPAN style="font-family: courier new,courier;"&gt;stat_point&lt;/SPAN&gt; function mimics the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/near.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Near &lt;/A&gt;tool.&amp;nbsp; The Near tool is more performant than using &lt;SPAN style="font-family: courier new,courier;"&gt;stat_point&lt;/SPAN&gt; to find the minimum distance point, but &lt;SPAN style="font-family: courier new,courier;"&gt;stat_point&lt;/SPAN&gt; is orders of magnitude faster at finding non-nearest points compared to Point Distance or Generate Near Table.&amp;nbsp; Of course, &lt;SPAN style="font-family: courier new,courier;"&gt;stat_point&lt;/SPAN&gt; is doing planar measurements so that is something to be aware of.&amp;nbsp; I threw MEDIAN parameters in as an example of how simple it is to extend this methodology beyond minimum or maxiumum points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The NumPy heavy lifting, lines 43-45, comes from Alex Martelli in response to a Stack Overflow post:&amp;nbsp; &lt;A href="http://stackoverflow.com/questions/1871536/euclidean-distance-between-points-in-two-different-numpy-arrays-not-within" rel="nofollow noopener noreferrer" target="_blank"&gt;Euclidean distance between points in two different Numpy arrays, not within&lt;/A&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343822#M26947</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T16:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343823#M26948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should probably read this more closely, but I've used &lt;A href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.distance.pdist.html"&gt;scipy.spatial.distance.pdist&lt;/A&gt; for approximately what I think may be happening in lines 43-45 (pairwise distances?).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 21:27:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343823#M26948</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-24T21:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343824#M26949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I stuck with NumPy because SciPy isn't shipped with ArcGIS Desktop, yet, and SciPy isn't part of our standard data center Python deployment either.&amp;nbsp; From a performance perspective, it would be interesting to compare the two approaches.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 21:41:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343824#M26949</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-24T21:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding furthest distances between two sets of points</title>
      <link>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343825#M26950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just ran a quick test between stat_point() and the following function for 1,000 points and the results are: stat_point() - 29s, numpyNear() - 0.5s. Almost of the stat_point() time is due to calls to arcpy.Describe (14.1s) and arcpy.AddField (14.7s), so the numpy stuff isn't the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;... def numpyNear(fc):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; npArray = arcpy.da.FeatureClassToNumPyArray(fc,["OID@","SHAPE@XY"])
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distArray = scipy.spatial.distance.pdist(npArray['SHAPE@XY'],'euclidean')
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqDistArray = scipy.spatial.distance.squareform(distArray)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nearFID = npArray['OID@'][numpy.argsort(sqDistArray)[:,1]].transpose()
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; npAppend = numpy.lib.recfunctions.append_fields(npArray,'NearFID',nearFID)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nearDist = numpy.sort(sqDistArray)[:,1].transpose()
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; npAppend = numpy.lib.recfunctions.append_fields(npAppend,'NearDist',nearDist)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFC = r'in_memory\outPts'+str(random.random()*1000)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeat = arcpy.da.NumPyArrayToFeatureClass(npAppend,outFC,"SHAPE@XY")
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(outFC,r'in_memory\numpy_Pts')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-furthest-distances-between-two-sets-of/m-p/343825#M26950</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T16:12:27Z</dc:date>
    </item>
  </channel>
</rss>

