<?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: How to Select By Location and Attribute? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78300#M2743</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to address Point 1, however I'm still uncertain on how to Select By Attribute based on the most similar value rather than an exact value.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Feb 2015 05:13:58 GMT</pubDate>
    <dc:creator>ChittayongSurakitbanharn</dc:creator>
    <dc:date>2015-02-25T05:13:58Z</dc:date>
    <item>
      <title>How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78296#M2739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 120 individual data points (each representing a small airport) that I would like to perform the following analysis:&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;Select a county that the airport is located in and extract a statistic from that county (e.g. income/capita).&amp;nbsp; Let’s call this County A and the statistic X.&lt;/LI&gt;&lt;LI&gt;Select another county (let’s call it County B) subjected to the following constraint: County B must be intersected by a circle of the same geodesic radius as the distance between the airport in County A and a central location.&lt;OL style="list-style-type: lower-alpha;"&gt;&lt;LI&gt;The selection of County B should be based on another given statistic of County B being most similar to County A.&amp;nbsp; Let’s call this selection criteria statistic Y.&amp;nbsp; (E.g. If statistic Y is population, I would like to select the county with closest population to County A that is intersected by the circle.)&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Extract the names of County A, B as well as statistic X, Y for County A and B to a table.&lt;/LI&gt;&lt;LI&gt;Repeat for the other rows of data (i.e. the other small airports and central locations they are paired with.)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The image below is an example of one of these situations.&amp;nbsp; The small green dot towards the right is the airport in consideration, the selected county is County A in this situation.&amp;nbsp; Thus, County B is the county that is closest to County A for a statistic Y (e.g. most similar in population) and is intersected by the geodesic circle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="64993" alt="2015__02_23-Select_EAS_county.JPG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/64993_2015__02_23-Select_EAS_county.JPG" style="width: 620px; height: 359px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this is a combination of Selection by Location and Selection by Attribute.&amp;nbsp; Would Model Builder be the best approach for this problem?&lt;/P&gt;&lt;P&gt;Thanks ahead for the help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jao&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 07:24:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78296#M2739</guid>
      <dc:creator>ChittayongSurakitbanharn</dc:creator>
      <dc:date>2015-02-24T07:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78297#M2740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have to tried this in modelbuilder for one case?&amp;nbsp; If so you can examine the use of iterators in modelbuilder to automate the workflow.&amp;nbsp; Examples are available in the help files once you get a single case working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 01:02:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78297#M2740</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-25T01:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78298#M2741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use python for something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First in arc I would cut the counties with a intersect and your circle. Using this and your airports as input to the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the columns of interest into lists (arrays) and then iterate over the lists and do the matching. Then output data to a new table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000"&gt;&lt;SPAN class="arcpyref" style="font-size: 12.8000001907349px; font-family: 'Courier New', Courier, monospace; font-weight: bold; color: #4d4d4d;"&gt;SearchCursor &lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt; &lt;/SPAN&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000064000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000064000000"&gt;&lt;SPAN class="arcpyref" style="font-size: 12.8000001907349px; font-family: 'Courier New', Courier, monospace; font-weight: bold; color: #4d4d4d;"&gt;UpdateCursor&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Arial, Helvetica, sans-serif; font-size: 12.8000001907349px;"&gt; &lt;/SPAN&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.tutorialspoint.com/python/" title="http://www.tutorialspoint.com/python/"&gt;Python tutorial&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have not used python before this may look very hard at first. But it is not that bad as it is a small code project. I would think the hardest part would be the logic in the matching. That could be harder depending on the complexity of your criteria.... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 02:55:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78298#M2741</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2015-02-25T02:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78299#M2742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a bit stuck on the modeling for even one case.&amp;nbsp; The two specific points I'm stuck on for modeling one case is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How do I select all the county polygons which are intersected by the edge of my circle polygon?&lt;/LI&gt;&lt;LI&gt;How do I select by attribute based on the most similar value rather than an exact value?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 02:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78299#M2742</guid>
      <dc:creator>ChittayongSurakitbanharn</dc:creator>
      <dc:date>2015-02-25T02:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78300#M2743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to address Point 1, however I'm still uncertain on how to Select By Attribute based on the most similar value rather than an exact value.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 05:13:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78300#M2743</guid>
      <dc:creator>ChittayongSurakitbanharn</dc:creator>
      <dc:date>2015-02-25T05:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78301#M2744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I addressed Point 2 using a Similarity Search tool.&amp;nbsp; Just need to iterate now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 07:39:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78301#M2744</guid>
      <dc:creator>ChittayongSurakitbanharn</dc:creator>
      <dc:date>2015-02-25T07:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Select By Location and Attribute?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78302#M2745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This sounds like fun, so I tried something and this is the result:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="county01.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/65490_county01.png" style="width: 620px; height: 256px;" /&gt;&lt;/P&gt;&lt;P&gt;and this is what the connecting lines look like:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="county02.png" class="jive-image image-2" src="https://community.esri.com/legacyfs/online/65491_county02.png" style="width: 620px; height: 441px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code used. Change lines according to your data and needs:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;6 input featureclass&lt;/LI&gt;&lt;LI&gt;7, 8 and 9 the input fields&lt;/LI&gt;&lt;LI&gt;12 the output connector featureclass&lt;/LI&gt;&lt;LI&gt;15 the distance for the buffer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; # inputs
&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = r"D:\Xander\GeoNet\County\data.gdb\Counties_test"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_id = "GEOID"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_name = "NAME"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_pop = "POP010210D"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # output for validation
&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_out = r"D:\Xander\GeoNet\County\data.gdb\connections03"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # the geodesic distance
&amp;nbsp;&amp;nbsp;&amp;nbsp; distance = "300000 Meters"

&amp;nbsp;&amp;nbsp;&amp;nbsp; # internal settings
&amp;nbsp;&amp;nbsp;&amp;nbsp; ws_mem = "IN_MEMORY"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput = True
&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = arcpy.Describe(fc).spatialReference

&amp;nbsp;&amp;nbsp;&amp;nbsp; # create featurelayer for selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc, "county_lyr")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # list to store output conector lines (between counties)
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_feats = []

&amp;nbsp;&amp;nbsp;&amp;nbsp; # start search cursor over counties
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = ("SHAPE@", fld_id, fld_name, fld_pop)
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(fc, flds) as curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geoid = row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = row[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pop = int(row[3])

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # determine label point in input county
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = polygon.labelPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pntg = arcpy.PointGeometry(pnt, sr)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # buffer label point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_tmp = os.path.join(ws_mem, "tmp_buf")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(in_features=pntg, out_feature_class=fc_tmp,
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer_distance_or_field=distance,
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method="GEODESIC")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # get first feature of buffer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf_pol = arcpy.da.SearchCursor(fc_tmp, ("SHAPE@",)).next()[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # boundary = buf_pol.boundary()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # lst_feats.append(boundary)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # select by location
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("county_lyr", "CROSSED_BY_THE_OUTLINE_OF",
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf_pol, selection_type="NEW_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # search selected counties for similar population
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min_dif = 999999
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor("county_lyr", flds) as curs_s:
&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; for row_s in curs_s:
&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; pnt_s = row_s[0].labelPoint
&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; pop2 = int(row_s[3])
&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; dif = abs(pop - pop2)
&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; if dif &amp;lt; min_dif:
&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; # found a county
&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; min_dif = dif
&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; pop_found = pop2
&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; geoid_found = row_s[1]
&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; name_found = row_s[2]
&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; pnt_found = arcpy.Point(pnt_s.X, pnt_s.Y)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create line between two counties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = arcpy.Polyline(arcpy.Array([pnt, pnt_found]), sr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_feats.append(line)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print result
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}".format(name, geoid, pop, name_found, geoid_found, pop_found, min_dif)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # copy line features to output featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(lst_feats, fc_out)


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:01:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-select-by-location-and-attribute/m-p/78302#M2745</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T23:01:00Z</dc:date>
    </item>
  </channel>
</rss>

