<?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: absolute minimum value selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466290#M36446</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Looks good, much more fleshed out. Maybe I am missing something though, this doesn't seem to preserve the negative sign with the xmin assignment.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You're right--it doesn't preserve the sign.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think you need it as long as you use the ABS function in the second SearchCursor SQL expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Arc 10 help: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000"&gt;SQL reference for query expressions used in ArcGIS&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Aug 2012 19:11:27 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2012-08-08T19:11:27Z</dc:date>
    <item>
      <title>RE: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466286#M36442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a file geodatabase table with a field titled "min_value". Within this field there are values from -1000 to +1000. I am trying to search all of the rows in the table to select the row with the lowest absolute value within the "min_value" field (ie. value +/- closest to zero). I will then be using a value (shapefile name) within the same row (but different field) to identify which shapefile to use in the next processing step of the script. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank-you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 15:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466286#M36442</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2012-08-08T15:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466287#M36443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There may be a better way, but here's the best solution I could find.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;curs =&amp;nbsp; arcpy.SearchCursor(table) for row in curs: &amp;nbsp;&amp;nbsp;&amp;nbsp; listing.append(row.min_value)&amp;nbsp; print min((abs(0 - i), i) for i in listing)[1]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could also pass the OID or some other identifier to go back to the row object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 16:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466287#M36443</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-08T16:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466288#M36444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Matt - I guess I have a tweak:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
tv = arcpy.MakeTableView(table)
curs =&amp;nbsp; arcpy.SearchCursor(tv)
listing = list() # create a list
for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.append(row.min_value)
del row, curs # always a good idea when done!
xmin = min([abs(i) for i in listing])
# now get that record (or the first if several) with that abs value
curs = SearchCursor(tv,"abs(%s) = %s" % (min_value,xmin))
# get the value for field "shapefile"
shapefile = curs.next().shapefile
del curs
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466288#M36444</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T20:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466289#M36445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Matt - I guess I have a tweak:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
tv = arcpy.MakeTableView(table)
curs =&amp;nbsp; arcpy.SearchCursor(tv)
listing = list() # create a list
for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.append(row.min_value)
del row, curs # always a good idea when done!
xmin = min([abs(i) for i in listing])
# now get that record (or the first if several) with that abs value
curs = SearchCursor(tv,"abs(%s) = %s" % (min_value,xmin))
# get the value for field "shapefile"
shapefile = curs.next().shapefile
del curs
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks good, much more fleshed out. Maybe I am missing something though, this doesn't seem to preserve the negative sign with the xmin assignment.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:41:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466289#M36445</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T20:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466290#M36446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Looks good, much more fleshed out. Maybe I am missing something though, this doesn't seem to preserve the negative sign with the xmin assignment.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You're right--it doesn't preserve the sign.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think you need it as long as you use the ABS function in the second SearchCursor SQL expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Arc 10 help: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000"&gt;SQL reference for query expressions used in ArcGIS&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 19:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466290#M36446</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-08-08T19:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: absolute minimum value selection</title>
      <link>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466291#M36447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah yes, makes sense. Doesn't really matter if they are positive or negative if they are the same absolute value anyways.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 19:21:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/re-absolute-minimum-value-selection/m-p/466291#M36447</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-08T19:21:11Z</dc:date>
    </item>
  </channel>
</rss>

