<?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: determining maximum cell from a Numpy array in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176093#M13555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your list syntax is incorrect.&amp;nbsp; You need to use commas between values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find out about type formatting at python.org.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Dec 2012 14:33:16 GMT</pubDate>
    <dc:creator>AndrewChapkowski</dc:creator>
    <dc:date>2012-12-11T14:33:16Z</dc:date>
    <item>
      <title>determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176090#M13552</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 large numpy array and i would like to write a python script for assigning zero (0) to every maximum cell in every four adjacent cells. For example, see figure below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]19775[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be very much appreciated, thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 07:12:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176090#M13552</guid>
      <dc:creator>BarbaraLokes</dc:creator>
      <dc:date>2012-12-07T07:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176091#M13553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can find a value positions by doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp; itemindex=numpy.where(array==item)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then change your values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find the max value by doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; from numpy import *
&amp;gt;&amp;gt;&amp;gt; a = array([10,20,30])
&amp;gt;&amp;gt;&amp;gt; a.max()
30
&amp;gt;&amp;gt;&amp;gt; a = array([[10,50,30],[60,20,40]])
&amp;gt;&amp;gt;&amp;gt; a.max()
60
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&amp;nbsp; You can find more information about numpy by going to the scipy.org site.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176091#M13553</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-11T09:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176092#M13554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;tried this with a sample 6x6 grid. i´d really like to know if there´s a better way (i´m sure there is) using more numpy/scipy (tried that at first but couldn´t really get it working).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;anyways...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[[&amp;nbsp; 5.4&amp;nbsp;&amp;nbsp; 7.5&amp;nbsp;&amp;nbsp; 2.2&amp;nbsp;&amp;nbsp; 8.5&amp;nbsp;&amp;nbsp; 8.6&amp;nbsp;&amp;nbsp; 7.5]
 [&amp;nbsp; 7.7&amp;nbsp;&amp;nbsp; 3.5&amp;nbsp;&amp;nbsp; 1.4&amp;nbsp;&amp;nbsp; 9.6&amp;nbsp;&amp;nbsp; 8.5&amp;nbsp;&amp;nbsp; 5.5]
 [&amp;nbsp; 5.2&amp;nbsp;&amp;nbsp; 6.1&amp;nbsp;&amp;nbsp; 8.6&amp;nbsp;&amp;nbsp; 6.7&amp;nbsp;&amp;nbsp; 4.3&amp;nbsp;&amp;nbsp; 6.8]
 [&amp;nbsp; 9.3&amp;nbsp;&amp;nbsp; 4.5&amp;nbsp;&amp;nbsp; 2.7&amp;nbsp;&amp;nbsp; 3.6&amp;nbsp;&amp;nbsp; 6.7&amp;nbsp;&amp;nbsp; 4.5]
 [&amp;nbsp; 1.2&amp;nbsp;&amp;nbsp; 2.3&amp;nbsp;&amp;nbsp; 7.2&amp;nbsp;&amp;nbsp; 6.3&amp;nbsp;&amp;nbsp; 2.2&amp;nbsp;&amp;nbsp; 2. ]
 [&amp;nbsp; 1.3&amp;nbsp;&amp;nbsp; 2.&amp;nbsp; -99.&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.&amp;nbsp; -99.&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.2]]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
nrows=6
ncols=6
for row in range(0, nrows -1, 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for col in range(0, ncols -1, 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # current 2x2 subgrid&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; curgrid = {grid[row,col]:(row,col), grid[row, col+1]:(row, col+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; grid[row+1,col]:(row+1,col), grid[row+1, col+1]:(row+1, col+1)}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set max of current subgrid in the totalgrid to 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid[curgrid[max(curgrid)]] = 0&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;out:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[[&amp;nbsp; 5.4&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.2&amp;nbsp;&amp;nbsp; 8.5&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 7.5]
 [&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.5&amp;nbsp;&amp;nbsp; 1.4&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.5]
 [&amp;nbsp; 5.2&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0. ]
 [&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.7&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0. ]
 [&amp;nbsp; 1.2&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0. ]
 [&amp;nbsp; 1.3&amp;nbsp;&amp;nbsp; 0.&amp;nbsp; -99.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.&amp;nbsp; -99.&amp;nbsp;&amp;nbsp;&amp;nbsp; 0. ]]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:05:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176092#M13554</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2021-12-11T09:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176093#M13555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your list syntax is incorrect.&amp;nbsp; You need to use commas between values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find out about type formatting at python.org.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Dec 2012 14:33:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176093#M13555</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2012-12-11T14:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176094#M13556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the input is an array&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;print type(grid)
&amp;lt;type 'numpy.ndarray'&amp;gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176094#M13556</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2021-12-11T09:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176095#M13557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try putting commas after each number.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code worked then.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 09:18:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176095#M13557</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2012-12-12T09:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: determining maximum cell from a Numpy array</title>
      <link>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176096#M13558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the code works for me as well. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i just said that i would also be very interested in a more/only numpy-based approach.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 11:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/determining-maximum-cell-from-a-numpy-array/m-p/176096#M13558</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2012-12-12T11:28:50Z</dc:date>
    </item>
  </channel>
</rss>

