<?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 Point Distance based on Attributes in Spatial Data Science Questions</title>
    <link>https://community.esri.com/t5/spatial-data-science-questions/point-distance-based-on-attributes/m-p/49540#M84</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the easiest way to calculate the distance between 2 points, from 2 different features, that have matching attribute?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gary Barden&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 May 2015 17:46:58 GMT</pubDate>
    <dc:creator>GaryBarden</dc:creator>
    <dc:date>2015-05-26T17:46:58Z</dc:date>
    <item>
      <title>Point Distance based on Attributes</title>
      <link>https://community.esri.com/t5/spatial-data-science-questions/point-distance-based-on-attributes/m-p/49540#M84</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the easiest way to calculate the distance between 2 points, from 2 different features, that have matching attribute?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gary Barden&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 17:46:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-data-science-questions/point-distance-based-on-attributes/m-p/49540#M84</guid>
      <dc:creator>GaryBarden</dc:creator>
      <dc:date>2015-05-26T17:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Point Distance based on Attributes</title>
      <link>https://community.esri.com/t5/spatial-data-science-questions/point-distance-based-on-attributes/m-p/49541#M85</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gary,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could accomplish this with a python script that uses the &lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/analysis/point-distance.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Point Distance&lt;/A&gt; tool.&amp;nbsp; Below is an example that creates an individual feature layer based on an attribute selection for each feature class, and then runs the point distance analysis on these two points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"
env.overwriteOutput = 1

fc1 = "pointA"
fc2 = "pointB"

#retrieve unique field values
valueList = []
with arcpy.da.SearchCursor(fc1, ["PIN"]) as cursor:
&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(row[0])

del cursor

#run Point Distance analysis
firstTime = 1

for value in valueList:
&amp;nbsp; if firstTime == 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc1, "fcLyrA", "PIN = '" + value + "'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc2, "fcLyrB", "PIN = '" + value + "'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PointDistance_analysis("fcLyrA", "fcLyrB", r"IN_MEMORY\pointDistance")
&amp;nbsp;&amp;nbsp;&amp;nbsp; firstTime = 2
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc1, "fcLyrA", "PIN = '" + value + "'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc2, "fcLyrB", "PIN = '" + value + "'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PointDistance_analysis("fcLyrA", "fcLyrB", r"IN_MEMORY\pointDistance_" + str(value))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Append_management(r"IN_MEMORY\pointDistance_" + str(value), r"IN_MEMORY\pointDistance")

#export table results&amp;nbsp;&amp;nbsp;&amp;nbsp; 
arcpy.CopyRows_management(r"IN_MEMORY\pointDistance", "pointDistanceResults")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:54:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-data-science-questions/point-distance-based-on-attributes/m-p/49541#M85</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T21:54:37Z</dc:date>
    </item>
  </channel>
</rss>

