<?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: reclassify using Numpy, out of memory in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339738#M26631</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data type of the array must be integer, I think you still have floating point values, so here is a sample, converting one of my random integer .npy files into an integer, an image, then a polygon&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; az
array([[&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 6., ...,&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 4.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 0., ...,&amp;nbsp; 0.,&amp;nbsp; 2.,&amp;nbsp; 0.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0.,&amp;nbsp; 4.,&amp;nbsp; 0., ...,&amp;nbsp; 10.,&amp;nbsp; 0.,&amp;nbsp; 0.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 2.,&amp;nbsp; 0.,&amp;nbsp; 0., ...,&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 2.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 0., ...,&amp;nbsp; 0.,&amp;nbsp; 8.,&amp;nbsp; 0.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 10.,&amp;nbsp; 4.,&amp;nbsp; 0., ...,&amp;nbsp; 0.,&amp;nbsp; 0.,&amp;nbsp; 6.]])
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; eee_zee = az.astype(int)
&amp;gt;&amp;gt;&amp;gt; eee_zee
array([[ 0,&amp;nbsp; 0,&amp;nbsp; 6, ...,&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 4],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 0,&amp;nbsp; 0,&amp;nbsp; 0, ...,&amp;nbsp; 0,&amp;nbsp; 2,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 0,&amp;nbsp; 4,&amp;nbsp; 0, ..., 10,&amp;nbsp; 0,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 2,&amp;nbsp; 0,&amp;nbsp; 0, ...,&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 2],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 0,&amp;nbsp; 0,&amp;nbsp; 0, ...,&amp;nbsp; 0,&amp;nbsp; 8,&amp;nbsp; 0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [10,&amp;nbsp; 4,&amp;nbsp; 0, ...,&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp; 6]])
&amp;gt;&amp;gt;&amp;gt; out = arcpy.NumPyArrayToRaster(eee_zee)
&amp;gt;&amp;gt;&amp;gt; out.save("f:/temp/ez.tif")
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; p = arcpy.RasterToPolygon_conversion("f:/temp/ez.tif","f:/temp/ez_.shp","NO_SIMPLIFY")
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, you have to be aware that it will make many unique areas IF you have many areas. That could be limitation&lt;/P&gt;&lt;P&gt;I just used the no_simplify and sent it out to a shapefile which loaded into arcmap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The keep line is eee_zee = az.astype(int)&amp;nbsp; ... that sent the floating point array to an integer view.&amp;nbsp; Then I saved it to a raster (tif) then to a shapefile&lt;/P&gt;&lt;P&gt;Next step... I want to see an image of what you are working with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS&amp;nbsp; in Global Reach, it has had 2163 view but only 12 people...&lt;/P&gt;&lt;P&gt;so these people...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;have no life other than to view this thread multiple times,&lt;/LI&gt;&lt;LI&gt;there a whole load of unsigned in people reading this thread or&lt;/LI&gt;&lt;LI&gt;there is something wrong with global reach views&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp; &lt;A href="https://community.esri.com/migrated-users/2034" target="_blank"&gt;Timothy Hales&lt;/A&gt;​ can you provide some insight&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:03:53 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T16:03:53Z</dc:date>
    <item>
      <title>reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339713#M26606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;EDIT: although I marked Dan's answer re: making the array an integer array, which was the last piece I needed, I created a summary at the end &lt;A _jive_internal="true" href="https://community.esri.com/message/610325#comment-610325" title="https://community.esri.com/message/610325#comment-610325" target="_blank"&gt;&lt;SPAN style="color: #e23d39;"&gt;https://community.esri.com/message/610325#comment-610325&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; to put all the pieces that worked together.&amp;nbsp; I suggest starting there if running into this problem.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bottom line:&lt;/STRONG&gt; trying to get reclass elevation raster (in m), that include “water” and NoData, and Denali foothills, to 3-4 class (based on feet---keeping the converted layer, not&amp;nbsp; in memory), then convert to polygons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the study are I used for development (and one other), the raster &lt;EM&gt;Reclassify&lt;/EM&gt; and &lt;EM&gt;arcpy.RasterToPolygon_conversion &lt;/EM&gt; this worked relatively fast. (max few minutes)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’m now running it on an area about 2x larger (~25m cells, 6657 col 13035 row), with a wider range of input values.&amp;nbsp; When using my script/tool or testing in the python window, I run out of memory after about 4 hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I’m diving into Numpy and &lt;A _jive_internal="true" href="https://community.esri.com/people/Dan_Patterson" target="_blank"&gt;https://community.esri.com/people/Dan_Patterson&lt;/A&gt; ‘s blog &lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/03/12/reclassify-raster-data-simply" target="_blank"&gt;https://community.esri.com/blogs/dan_patterson/2016/03/12/reclassify-raster-data-simply&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After a clean reboot, I’m trying my test script in the python window, but I’m still getting an out of error message.&amp;nbsp; I’m not sure if I have something in error in my script, or it is just too large for the 32bit-python to handle.&amp;nbsp; So, I’m open to suggestions…..maybe processing half at a time??&amp;nbsp; I have tried but a full raster with no nodata, and one that has nodata outside the side area boundary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test script I am using (parts borrowed from Dan's demo scripts)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import time
import os
import arcpy
from arcpy import env
from arcpy.sa import *
import numpy as np
from textwrap import dedent

arcpy.CheckOutExtension("spatial")

def arr_reclass(a, bins=[], new_bins=[], mask=False, mask_val=None):
&amp;nbsp; """a&amp;nbsp;&amp;nbsp;&amp;nbsp; - integer or floating point array to be reclassed using
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bins - sequential list/array of the lower limits of each class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; include one value higher to cover the upper range.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mask - whether the raster contains nodata values or values to
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; be masked with mask_val
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array dimensions will be squeezed 
&amp;nbsp; """ 
&amp;nbsp; a_rc = np.zeros_like(a)
&amp;nbsp; if (len(bins) &amp;lt; 2): # or (len(new_bins &amp;lt;2)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Bins = {} new = {} won't work".format(bins,new_bins))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return a
&amp;nbsp; if len(new_bins) &amp;lt; 2:
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins = np.arange(1,len(bins)+2)&amp;nbsp;&amp;nbsp; 
&amp;nbsp; new_classes = zip(bins[:-1],bins[1:],new_bins)
&amp;nbsp; for rc in new_classes:
&amp;nbsp;&amp;nbsp;&amp;nbsp; q1 = (a &amp;gt;= rc[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; q2 = (a &amp;lt; rc[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; z = np.where(q1 &amp;amp; q2, rc[2],0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; a_rc = a_rc + z
&amp;nbsp; return a_rc

theWorkspace = r'C:\___bear2016\_Skwentna2017\Skwentna_prep.gdb'
arcpy.env.workspace = theWorkspace
arcpy.env.overwriteOutput = True
wsPath, wsGDB = os.path.split(theWorkspace)
print("Project gdb (vector, i.e. for points, lines, polygons): {0}".format(theWorkspace))

inStudy = r'C:\___bear2016\_Skwentna2017\Skwentna_prep.gdb\Study16b'
stdyPath, stdyName = os.path.split(inStudy)
print("Study boundary: {0}".format(stdyName))
spatialref = arcpy.Describe(inStudy).spatialReference

rasterIn = r'C:\___bear2016\_Skwentna2017\Skwentna_raster.gdb\elevExtent'
#rasterIn = r'C:\___bear2016\_Skwentna2017\Skwentna_raster.gdb\elevClip'
inRas = arcpy.Raster(rasterIn)

lowerLeft = arcpy.Point(inRas.extent.XMin, inRas.extent.YMin)
cellSize = inRas.meanCellWidth

rasterGDB, rasterFile = os.path.split(rasterIn)
elevUnits = "meters"
elevCutoffFt = "6000"
flatElevBreak = "2000"
elevBreaks = flatElevBreak.split("; ")
elevBreaks.sort(key=float)&amp;nbsp; 
flatElevBreak = ";".join(elevBreaks)
flatElevBreak
'2000'
hydroBuff = r'C:\___bear2016\_Skwentna2017\Skwentna_prep.gdb\hydroBuff250'
finalTransZones = arcpy.os.path.join(theWorkspace, "TransAreas")
outRiparian = arcpy.os.path.join(theWorkspace, "TransRiparian")
pElevClass = arcpy.os.path.join(theWorkspace, "elevReclassPoly")&amp;nbsp; 
outDEMtmp = arcpy.os.path.join(theWorkspace, "elevReclass")&amp;nbsp; 

if elevUnits == "meters":&amp;nbsp;&amp;nbsp; #&amp;nbsp; 3.280839895013123
&amp;nbsp; toElevFeet = 3.28084
else:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # note, IF had to go from feet to meters, factor would be 0.3048
&amp;nbsp; toElevFeet = 1
elevFeet = (inRas * toElevFeet)
saveElevFeet = arcpy.os.path.join(rasterGDB, "elevFt")
elevFeet.save(saveElevFeet)
elevMin = elevFeet.minimum&amp;nbsp; - 1
elevMax = elevFeet.maximum&amp;nbsp; + 1
noDataReclass = 99999

elevSplit = flatElevBreak.split(";")
lstCnt = 1
#reclassArg = []
bins = []
new_bins = []
for reclassValue in elevSplit:
&amp;nbsp; if lstCnt == 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #reclassArg.append([int(elevMin), int(reclassValue), int(reclassValue)])
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins.append(int(elevMin))
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins.append(int(-1))
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins.append(int(reclassValue))
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins.append(int(-1))
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins.append(int(reclassValue))
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #reclassArg.append([int(prevValue), int(reclassValue), int(reclassValue)])
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins.append(int(reclassValue))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins.append(int(0))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins.append(int(reclassValue))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; lstCnt += 1
&amp;nbsp; prevValue = reclassValue
#reclassArg.append([int(prevValue), int(elevCutoffFt), int(elevCutoffFt)])
#reclassArg.append([int(elevCutoffFt), int(elevMax), 9])

bins.append(int(elevCutoffFt))
bins.append(int(elevMax))
new_bins.append(int(elevCutoffFt))
new_bins.append(9)&amp;nbsp; 
new_classes = zip(bins[:-1],bins[1:],new_bins)

print("&amp;nbsp;&amp;nbsp; ...Old Ranges:\n&amp;nbsp;&amp;nbsp; {0}".format(bins))
print("&amp;nbsp;&amp;nbsp; ...New values:\n&amp;nbsp;&amp;nbsp; {0}".format(new_bins))
print("&amp;nbsp;&amp;nbsp; ...New classes:\n&amp;nbsp;&amp;nbsp; {0}".format(new_classes))


arr = arcpy.RasterToNumPyArray(inRas, nodata_to_value=9999999)
mask = False
mask_val = None
print(arr)
arr_rc = arr_reclass(arr, bins=bins, new_bins=new_bins)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I am getting is on the last line, however, looking at the resources, there is plenty of RAM available, so I'm assuming it is just the Arcmap/Python limit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output from script (in ArcMap python window)&lt;/P&gt;&lt;P&gt;Project gdb (vector, i.e. for points, lines, polygons): C:\___bear2016\_Skwentna2017\Skwentna_prep.gdb&lt;/P&gt;&lt;P&gt;Study boundary: Study16b&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt; ...Old Ranges:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [-107504, -1, 2000, 6000, 20036]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...New values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [-1, 2000, 6000, 9]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...New classes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [(-107504, -1, -1), (-1, 2000, 2000), (2000, 6000, 6000), (6000, 20036, 9)]&lt;/P&gt;&lt;P&gt;[[&amp;nbsp; 205.16717529&amp;nbsp;&amp;nbsp; 205.25009155&amp;nbsp;&amp;nbsp; 205.29598999 ...,&amp;nbsp; 1037.9387207&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1037.86242676&amp;nbsp; 1037.83959961]&lt;/P&gt;&lt;P&gt; [&amp;nbsp; 205.22860718&amp;nbsp;&amp;nbsp; 205.3127594&amp;nbsp;&amp;nbsp;&amp;nbsp; 205.37818909 ...,&amp;nbsp; 1037.93701172&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1037.84533691&amp;nbsp; 1037.76965332]&lt;/P&gt;&lt;P&gt; [&amp;nbsp; 205.29447937&amp;nbsp;&amp;nbsp; 205.38237&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 205.46986389 ...,&amp;nbsp; 1037.91918945&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1037.75964355&amp;nbsp; 1037.76477051]&lt;/P&gt;&lt;P&gt; ..., &lt;/P&gt;&lt;P&gt; [ 1481.97961426&amp;nbsp; 1492.3326416&amp;nbsp;&amp;nbsp; 1504.91308594 ...,&amp;nbsp;&amp;nbsp; 510.62741089&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 504.97958374&amp;nbsp;&amp;nbsp; 501.19992065]&lt;/P&gt;&lt;P&gt; [ 1469.56079102&amp;nbsp; 1486.19445801&amp;nbsp; 1505.37487793 ...,&amp;nbsp;&amp;nbsp; 506.6071167&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 501.30090332&amp;nbsp;&amp;nbsp; 497.77194214]&lt;/P&gt;&lt;P&gt; [ 1453.34509277&amp;nbsp; 1471.94152832&amp;nbsp; 1493.07250977 ...,&amp;nbsp;&amp;nbsp; 501.66564941&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 497.09884644&amp;nbsp;&amp;nbsp; 494.20864868]]&lt;/P&gt;&lt;P&gt;Runtime error &lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 115, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 30, in arr_reclass&lt;/P&gt;&lt;P&gt;MemoryError&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I need to split it due to size, some guidance for that would be good.&amp;nbsp; The one nice thing about this numpy process, I get the error immediately instead of 4-hours in....&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps - Dan....is this question seen by more than the 13 members/followers?&amp;nbsp; Nice "place" but want to make sure others have a chance to find/reply&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tagging a few more areas&amp;nbsp; &lt;A href="https://community.esri.com/space/2145" target="_blank"&gt;Python&lt;/A&gt;​ &lt;A href="https://community.esri.com/group/1519" target="_blank"&gt;python snippets&lt;/A&gt;​ &lt;A href="https://community.esri.com/space/2161" target="_blank"&gt;Imagery and Remote Sensing&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339713#M26606</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T16:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339714#M26607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BTW - I ran the script above on the other study area, and it ran without any issue, i.e. no out of memory error, and I was able to use &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;test20a = arcpy.NumPyArrayToRaster(arr_rc)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to get it back into a raster, so that makes me believe that is it just an issue with the size of the raster (Col x row), so again, maybe there is an easy way for me to process half at a time, then merge them back....without having overlap/gap issues?&amp;nbsp; That is the approach I will take next if I don't get any better suggestions/options.&amp;nbsp; thanks again for looking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 23:20:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339714#M26607</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-05-19T23:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339715#M26608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;quick questions&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;python version (please say 3.4)&lt;/LI&gt;&lt;LI&gt;numpy version (please say 1.9.x)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;comment&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;how many rasters are you saving (count them) before you actually get to the array reclass???!!!&lt;/LI&gt;&lt;LI&gt;too many... they are still in memory and references to them don't get deleted until AFTER the array is reclassed&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;solution&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;prepare your array for reclassification or whatever, then do&lt;/LI&gt;&lt;LI&gt;np.save('c:/test/your_data.npy', your_array)&amp;nbsp; # saves in binary format&lt;/LI&gt;&lt;LI&gt;in_array = np.load('c:/test/your_data.npy')&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Homework&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; np.save('/tmp/123', np.array([[1, 2, 3], [4, 5, 6]]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; a = np.load('/tmp/123.npy')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt;&amp;nbsp; a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array([[1, 2, 3],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [4, 5, 6]])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if memory really sucks, you can read in bits&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mem-map the stored array, and then access the second row&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; directly from disk:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; X = np.load('/tmp/123.npy', mmap_mode='r')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; X[1, :]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; memmap([4, 5, 6])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will be up most of the night writing, so get back to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if we can't solve this, you may have to MOVE it to python, since it won't be 'seen' unless they have access to the N.R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 23:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339715#M26608</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-19T23:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339716#M26609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;quick questions&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;python version (please say 3.4)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #e23d39;"&gt;Default ArcGIS 10.3.1, so assuming 2.7&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;numpy version (please say 1.9.x)&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #e23d39;"&gt;same, so ??&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;comment&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;how many rasters are you saving (count them) before you actually get to the array reclass???!!!&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #e23d39;"&gt;only dealing with one raster/array...size specified in OP&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;too many... they are still in memory and references to them don't get deleted until AFTER the array is reclassed&amp;nbsp; &lt;SPAN style="color: #e23d39;"&gt;Just one reclass, and it crashes...rebooted to clear memory,&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;/UL&gt;&lt;P&gt;solution&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;prepare your array for reclassification or whatever, then do&lt;/LI&gt;&lt;LI&gt;np.save('c:/test/your_data.npy', your_array) # saves in binary format&lt;/LI&gt;&lt;LI&gt;in_array = np.load('c:/test/your_data.npy')&lt;/LI&gt;&lt;/UL&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;&lt;P&gt;Homework&lt;/P&gt;&lt;P&gt; &amp;gt;&amp;gt;&amp;gt; np.save('/tmp/123', np.array([[1, 2, 3], [4, 5, 6]]))&lt;/P&gt;&lt;P&gt; &amp;gt;&amp;gt;&amp;gt; a = np.load('/tmp/123.npy')&lt;/P&gt;&lt;P&gt; &amp;gt;&amp;gt;&amp;gt; a&lt;/P&gt;&lt;P&gt; array([[1, 2, 3],&lt;/P&gt;&lt;P&gt; [4, 5, 6]])&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;&lt;P&gt;Now if memory really sucks, you can read in bits&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;&lt;P&gt;Mem-map the stored array, and then access the second row&lt;/P&gt;&lt;P&gt; directly from disk:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;gt;&amp;gt;&amp;gt; X = np.load('/tmp/123.npy', mmap_mode='r')&lt;/P&gt;&lt;P&gt; &amp;gt;&amp;gt;&amp;gt; X[1, :]&lt;/P&gt;&lt;P&gt; memmap([4, 5, 6])&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'll give that a try.&amp;nbsp; Thanks for responding Dan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 23:59:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339716#M26609</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-05-19T23:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339717#M26610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did the "homework" so see how it should work, but when doing it with the real data, still getting memory issues&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;.....
arr = arcpy.RasterToNumPyArray(inRas, nodata_to_value=9999999)
np.save(r"C:\___bear2016\_Skwentna2017\outras.npy", arr)&amp;nbsp;&amp;nbsp; #save in binary format
in_array = np.load(r"C:\___bear2016\_Skwentna2017\outras.npy")
mask = False
mask_val = None
print(arr)
#arr_rc = arr_reclass(arr, bins=bins, new_bins=new_bins)
arr_rc = arr_reclass(in_array, bins=bins, new_bins=new_bins)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I think my best bet work be to find a "clean" and automated (since this will be done in different study areas) to split, reclass, con, and then convert to poly. I'll go ahead and move this to the python space to get more input.&amp;nbsp; (I like the design of you numpy space...very organized!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how much more I'll be able to work on this until Monday, but will try if I find anything that looks promising.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339717#M26610</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339718#M26611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works... here is the script and how I created a floating point array in the range 0-100.0 and reclassed to 8 bins of 1 to 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# coding: utf-8
"""
Script:&amp;nbsp; reclass_array_demo.py
&lt;SPAN&gt;Author:&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:Dan.Patterson@carleton.ca" rel="nofollow noopener noreferrer" target="_blank"&gt;Dan.Patterson@carleton.ca&lt;/A&gt;
Modified: 2016-05-19
Purpose: For Rebecca... array has no, nodata to simplify
References:
&amp;nbsp;&amp;nbsp;&amp;nbsp; RasterToNumPyArray and NumPyArrayToRaster can be used to and from
&amp;nbsp;&amp;nbsp;&amp;nbsp; raster formats of different types.
"""
import numpy as np
from textwrap import dedent
def arr_reclass(a, bins=[], new_bins=[], mask=False, mask_val=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """a&amp;nbsp;&amp;nbsp;&amp;nbsp; - integer or floating point array to be reclassed using
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bins - sequential list/array of the lower limits of each class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; include one value higher to cover the upper range.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mask - whether the raster contains nodata values or values to
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; be masked with mask_val
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array dimensions will be squeezed 
&amp;nbsp;&amp;nbsp;&amp;nbsp; """ 
&amp;nbsp;&amp;nbsp;&amp;nbsp; a_rc = np.zeros_like(a)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (len(bins) &amp;lt; 2): # or (len(new_bins &amp;lt;2)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Bins = {} new = {} won't work".format(bins,new_bins))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(new_bins) &amp;lt; 2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins = np.arange(1,len(bins)+2)&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_classes = zip(bins[:-1],bins[1:],new_bins)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for rc in new_classes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q1 = (a &amp;gt;= rc[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q2 = (a &amp;lt; rc[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z = np.where(q1 &amp;amp; q2, rc[2],0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a_rc = a_rc + z
&amp;nbsp;&amp;nbsp;&amp;nbsp; return a_rc

if __name__=="__main__":
&amp;nbsp;&amp;nbsp;&amp;nbsp; """For Rebecca&amp;nbsp; Uncomment the #z and #np.save lines to create the array, then you can load it blah blah"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; r = 7000
&amp;nbsp;&amp;nbsp;&amp;nbsp; c = 14000
&amp;nbsp;&amp;nbsp;&amp;nbsp; #z = np.abs(100 * np.random.random_sample((r,c)) -100)&amp;nbsp; # make an array with rand 0-100
&amp;nbsp;&amp;nbsp;&amp;nbsp; #np.save("f:/temp/z_7k_14k.npy",z)
&amp;nbsp;&amp;nbsp;&amp;nbsp; z = np.load("f:/temp/z_7k_14k.npy")
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins = [0,5,10,15,20,25,30,60,100]
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins = [1, 2, 3, 4, 5, 6, 7, 8]
&amp;nbsp;&amp;nbsp;&amp;nbsp; mask = False
&amp;nbsp;&amp;nbsp;&amp;nbsp; mask_val = None
&amp;nbsp;&amp;nbsp;&amp;nbsp; a_rc = arr_reclass(z, bins=bins, new_bins=new_bins)
&amp;nbsp;&amp;nbsp;&amp;nbsp; np.save("f:/temp/reclass_z_7k_14k.npy",a_rc)&lt;/PRE&gt;&lt;P&gt;So it works, but it too about 2 seconds to complete, so I may have to see if I can vectorize it some more to keep within in my one coffee sip requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here are the results which are as expected for the classes given and the sampling framework&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a_rc&lt;/P&gt;&lt;P&gt;array([[ 7.,&amp;nbsp; 6.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 8.],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..., &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 8.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 4.,&amp;nbsp; 6.],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 7.,&amp;nbsp; 7.,&amp;nbsp; 8.],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 2.,&amp;nbsp; 1.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 3.,&amp;nbsp; 8.]])&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a_rc.shape&lt;/P&gt;&lt;P&gt;(7000, 14000)&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; np.histogram(a_rc,bins=[1, 2, 3, 4, 5, 6, 7, 8])&lt;/P&gt;&lt;P&gt;(array([ 4903001,&amp;nbsp; 4898616,&amp;nbsp; 4900343,&amp;nbsp; 4899584,&amp;nbsp; 4898414,&amp;nbsp; 4901199, 68598843]), array([1, 2, 3, 4, 5, 6, 7, 8]))&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array size on disk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="reclassed_array.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/201546_reclassed_array.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339718#M26611</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339719#M26612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See my comments about saving and loading the array from disk.&amp;nbsp; Arcpy is notorious for stealing and not giving back.&amp;nbsp; Once you have your raster converted to an array, you don't need arcmap any more&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 00:33:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339719#M26612</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-20T00:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339720#M26613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that Dan, but even creating your random array, saving etc (and ~765 MB...2x the size of mine), I'm getting a memory error, although different than the "out_of_memory" I was getting before&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Runtime error&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 51, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 33, in arr_reclass&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;MemoryError&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My desktop is older, but semi-beefy...better than what most get.&amp;nbsp;&amp;nbsp;&amp;nbsp; I may try to run your script on my home machine to see if it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still think my best bet will be to split the array "in half" or thirds, process each separately, then merge them back together.&amp;nbsp; Just thinking out loud, but my guess that this would be a simple thing to do, once it is in an array.&amp;nbsp; Query the number of items, based on the size, decide how many parts, write each part to a file, load one at a time (overwriting the memory space) to do the reclass, write it back to disk, process the next.&amp;nbsp; Once done, stitch them back together and get it back into a raster for processing.&amp;nbsp;&amp;nbsp; what do you think??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, is there aeasy what to flush the memory if using this in a tool?&amp;nbsp; This will be part of my Toolbox (and maybe addin), run by various users and areas, so making it work...even if in chunks..is important.&amp;nbsp; I've tried using the function clearINMEM() by James Crandall, but my guess this isn't actually using the "IN_MEMORY" space ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(time for me to head home...)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 01:07:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339720#M26613</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-05-20T01:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339721#M26614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rebecca, the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/rastertonumpyarray-function.htm"&gt;RasterToNumpyArray&lt;/A&gt;​ function supports extracting smaller chunks from the raster using the {lower_left_corner}, {ncols}, {nrows} parameters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;RasterToNumPyArray (in_raster, {lower_left_corner}, {ncols}, {nrows}, {nodata_to_value})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could loop through and reclass a smaller array each time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 01:25:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339721#M26614</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-05-20T01:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339722#M26615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luke that is true, but you can keep arcpy out of it using mem-map which is essentially the same.&lt;/P&gt;&lt;P&gt;Mem-map supports 2 GB of memory, so I am not sure if it because I am using python 3.4.x and numpy 1.9.x for these tests (just using the ArcGIS Pro 1.2 install versions... nothing fancy this time)&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;I might be worth a while, since you have the array saved to disk, you can tile it, horizontally just to make stacking easier when you are done.&amp;nbsp; I will post an example later&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;From the help topic in np.load.....&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;Mem-map the stored array, and then access the second row&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; directly from disk:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; X = np.load('/tmp/123.npy', mmap_mode='r')&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; X[1, :]&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; memmap([4, 5, 6])&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 01:33:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339722#M26615</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-20T01:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339723#M26616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It may be split time...&amp;nbsp; &lt;/P&gt;&lt;P&gt;Now... you can create the array, save it to disk and load 'pieces', reclassify, save to disk, repeat then reassemble&lt;/P&gt;&lt;P&gt;I have no clue why you are running out of memory.&amp;nbsp; The arrays aren't that big, the processing within numpy barely makes a glitch time wise or memory wise.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I would suggest you monitor your memory useage.&amp;nbsp; How much ram do you have anyway? &lt;/P&gt;&lt;P&gt;Anyway, the below is a verbose description with results so you can see the process conceptually.&lt;/P&gt;&lt;P&gt;Later...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;replace the&amp;nbsp; below with, keeping the reclass function....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if __name__=="__main__":
&amp;nbsp;&amp;nbsp;&amp;nbsp; """run demo"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; r = 8
&amp;nbsp;&amp;nbsp;&amp;nbsp; c = 10
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; uncomment the 2 lines below to create the array only once, then recomment
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; for subsequent testing
&amp;nbsp;&amp;nbsp;&amp;nbsp; #z = np.abs(100 * np.random.random_sample((r,c)) - 100)&amp;nbsp; # make rand value in 0-100 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #np.save("z_8x10.npy",z) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; z = np.load("z_8x10.npy")
&amp;nbsp;&amp;nbsp;&amp;nbsp; bins = [0, 10, 20, 30, 40, 60, 70, 80, 90, 100]
&amp;nbsp;&amp;nbsp;&amp;nbsp; new_bins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&amp;nbsp;&amp;nbsp;&amp;nbsp; z_rc = arr_reclass(z, bins=bins, new_bins=new_bins)
&amp;nbsp;&amp;nbsp;&amp;nbsp; z_hist = np.histogram(z_rc,bins=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = np.array(list(zip(z_hist[1],z_hist[0])))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("input array\n{}\nreclassed array\n{}".format(z, z_rc))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("histogram....\n(class, count)\n{}".format(result))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # now reclass in slices and stack back
&amp;nbsp;&amp;nbsp;&amp;nbsp; z_rc0 = arr_reclass(z[:4,:], bins=bins, new_bins=new_bins)
&amp;nbsp;&amp;nbsp;&amp;nbsp; z_rc1 = arr_reclass(z[4:,:], bins=bins, new_bins=new_bins)
&amp;nbsp;&amp;nbsp;&amp;nbsp; z_stack = np.vstack((z_rc0,z_rc1))
&amp;nbsp;&amp;nbsp;&amp;nbsp; frmt="""
&amp;nbsp;&amp;nbsp;&amp;nbsp; Now split the array into some bits, do the reclass and reformulate
&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to use memmap (see np.load), it just reads the bits from disk
&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want, you can reuse the names to clear memory...this was not done
&amp;nbsp;&amp;nbsp;&amp;nbsp; in this case.&amp;nbsp; you can save intermediate results to disk as well.
&amp;nbsp;&amp;nbsp;&amp;nbsp; ....
&amp;nbsp;&amp;nbsp;&amp;nbsp; first split and reclass...
&amp;nbsp;&amp;nbsp;&amp;nbsp; {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; second...
&amp;nbsp;&amp;nbsp;&amp;nbsp; {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; all equal? np.allclose(z_stack, z_rc) = {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(dedent(frmt).format(z_rc0,z_rc1, np.allclose(z_stack, z_rc)))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;input array
[[ 57.04&amp;nbsp; 17.38&amp;nbsp; 74.4&amp;nbsp; 18.04&amp;nbsp; 25.&amp;nbsp;&amp;nbsp;&amp;nbsp; 99.25&amp;nbsp; 18.09&amp;nbsp; 9.79&amp;nbsp; 45.35&amp;nbsp; 67.94]
[ 28.73&amp;nbsp; 74.36&amp;nbsp; 32.13&amp;nbsp; 60.14&amp;nbsp; 0.79&amp;nbsp; 14.74&amp;nbsp; 60.81&amp;nbsp; 20.31&amp;nbsp; 53.26&amp;nbsp; 89.08]
[ 26.97&amp;nbsp; 70.29&amp;nbsp; 96.59&amp;nbsp; 43.5&amp;nbsp; 97.16&amp;nbsp; 96.33&amp;nbsp; 18.&amp;nbsp;&amp;nbsp;&amp;nbsp; 82.99&amp;nbsp; 35.37&amp;nbsp; 40.31]
[&amp;nbsp; 0.12&amp;nbsp; 52.13&amp;nbsp; 26.93&amp;nbsp; 19.59&amp;nbsp; 48.93&amp;nbsp; 20.31&amp;nbsp; 4.3&amp;nbsp; 24.43&amp;nbsp; 29.33&amp;nbsp; 20.46]
[ 85.84&amp;nbsp; 12.67&amp;nbsp; 94.1&amp;nbsp; 43.57&amp;nbsp; 76.68&amp;nbsp; 22.15&amp;nbsp; 93.13&amp;nbsp; 66.64&amp;nbsp; 61.31&amp;nbsp; 49.3 ]
[ 55.35&amp;nbsp; 25.44&amp;nbsp; 23.02&amp;nbsp; 62.98&amp;nbsp; 12.44&amp;nbsp; 83.66&amp;nbsp; 42.53&amp;nbsp; 92.32&amp;nbsp; 48.41&amp;nbsp; 24.&amp;nbsp; ]
[ 70.27&amp;nbsp; 45.64&amp;nbsp; 3.&amp;nbsp;&amp;nbsp;&amp;nbsp; 42.58&amp;nbsp; 73.27&amp;nbsp; 66.55&amp;nbsp; 1.68&amp;nbsp; 67.29&amp;nbsp; 48.39&amp;nbsp; 2.47]
[ 96.38&amp;nbsp; 4.19&amp;nbsp; 78.12&amp;nbsp; 82.1&amp;nbsp; 13.83&amp;nbsp; 73.13&amp;nbsp; 52.77&amp;nbsp; 28.02&amp;nbsp; 57.7&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.44]]
reclassed array
[[ 5.&amp;nbsp; 2.&amp;nbsp; 7.&amp;nbsp; 2.&amp;nbsp; 3.&amp;nbsp; 9.&amp;nbsp; 2.&amp;nbsp; 1.&amp;nbsp; 5.&amp;nbsp; 6.]
[ 3.&amp;nbsp; 7.&amp;nbsp; 4.&amp;nbsp; 6.&amp;nbsp; 1.&amp;nbsp; 2.&amp;nbsp; 6.&amp;nbsp; 3.&amp;nbsp; 5.&amp;nbsp; 8.]
[ 3.&amp;nbsp; 7.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 9.&amp;nbsp; 9.&amp;nbsp; 2.&amp;nbsp; 8.&amp;nbsp; 4.&amp;nbsp; 5.]
[ 1.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 2.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 1.&amp;nbsp; 3.&amp;nbsp; 3.&amp;nbsp; 3.]
[ 8.&amp;nbsp; 2.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 7.&amp;nbsp; 3.&amp;nbsp; 9.&amp;nbsp; 6.&amp;nbsp; 6.&amp;nbsp; 5.]
[ 5.&amp;nbsp; 3.&amp;nbsp; 3.&amp;nbsp; 6.&amp;nbsp; 2.&amp;nbsp; 8.&amp;nbsp; 5.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 3.]
[ 7.&amp;nbsp; 5.&amp;nbsp; 1.&amp;nbsp; 5.&amp;nbsp; 7.&amp;nbsp; 6.&amp;nbsp; 1.&amp;nbsp; 6.&amp;nbsp; 5.&amp;nbsp; 1.]
[ 9.&amp;nbsp; 1.&amp;nbsp; 7.&amp;nbsp; 8.&amp;nbsp; 2.&amp;nbsp; 7.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 5.&amp;nbsp; 1.]]
histogram....
(class, count)
[[ 1&amp;nbsp; 9]
[ 2&amp;nbsp; 9]
[ 3 14]
[ 4&amp;nbsp; 2]
[ 5 17]
[ 6&amp;nbsp; 8]
[ 7&amp;nbsp; 8]
[ 8&amp;nbsp; 5]
[ 9&amp;nbsp; 8]]


Now split the array into some bits, do the reclass and reformulate
If you want to use memmap (see np.load), it just reads the bits from disk
If you want, you can reuse the names to clear memory...this was not done
in this case.&amp;nbsp; you can save intermediate results to disk as well.
....
first split and reclass...
[[ 5.&amp;nbsp; 2.&amp;nbsp; 7.&amp;nbsp; 2.&amp;nbsp; 3.&amp;nbsp; 9.&amp;nbsp; 2.&amp;nbsp; 1.&amp;nbsp; 5.&amp;nbsp; 6.]
[ 3.&amp;nbsp; 7.&amp;nbsp; 4.&amp;nbsp; 6.&amp;nbsp; 1.&amp;nbsp; 2.&amp;nbsp; 6.&amp;nbsp; 3.&amp;nbsp; 5.&amp;nbsp; 8.]
[ 3.&amp;nbsp; 7.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 9.&amp;nbsp; 9.&amp;nbsp; 2.&amp;nbsp; 8.&amp;nbsp; 4.&amp;nbsp; 5.]
[ 1.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 2.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 1.&amp;nbsp; 3.&amp;nbsp; 3.&amp;nbsp; 3.]]
second...
[[ 8.&amp;nbsp; 2.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 7.&amp;nbsp; 3.&amp;nbsp; 9.&amp;nbsp; 6.&amp;nbsp; 6.&amp;nbsp; 5.]
[ 5.&amp;nbsp; 3.&amp;nbsp; 3.&amp;nbsp; 6.&amp;nbsp; 2.&amp;nbsp; 8.&amp;nbsp; 5.&amp;nbsp; 9.&amp;nbsp; 5.&amp;nbsp; 3.]
[ 7.&amp;nbsp; 5.&amp;nbsp; 1.&amp;nbsp; 5.&amp;nbsp; 7.&amp;nbsp; 6.&amp;nbsp; 1.&amp;nbsp; 6.&amp;nbsp; 5.&amp;nbsp; 1.]
[ 9.&amp;nbsp; 1.&amp;nbsp; 7.&amp;nbsp; 8.&amp;nbsp; 2.&amp;nbsp; 7.&amp;nbsp; 5.&amp;nbsp; 3.&amp;nbsp; 5.&amp;nbsp; 1.]]
all equal? np.allclose(z_stack, z_rc) = True&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339723#M26616</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339724#M26617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tend to read rasters directly to arrays in memory as chunks both because of the 2GB memmap limit and because it avoids the doubling up of file system IO (reading it in, saving it back out to npy, reading it back in).&amp;nbsp; But I'm usually dealing with large stacks of timeseries data.&amp;nbsp; Horses for courses &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 03:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339724#M26617</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-05-20T03:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339725#M26618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luke are you doing data prep and processing outside of Arc* ? or are you 'tiling' or equivalent when you mention chunks?&amp;nbsp; In this supposed world of big data, there seems little obvious interest in the data analysis side in the gis field.&amp;nbsp; Most complaints are the 1000 record limits for AGOL &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/confused.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 04:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339725#M26618</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-20T04:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339726#M26619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, I'll take a look at this tomorrow.&amp;nbsp; I did test your other script, i.e. creating the random array, on&amp;nbsp; my home win10 machine.&amp;nbsp; Again, 10.3.1 gave the memory error.&amp;nbsp; I then ran it in Pro (using the file written before the other crashed) and it worked, so that does point to the version of Python and/or numpy being an issue.&amp;nbsp; However, I do need to make this work in ArcMap, not Pro, so the split option seems like a better solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Luke, I think the speed of the numpy or similar is the way for me to go, especially if I can quickly split the array and remap. With the arcpy remap taking +4 hours of running before it ran into issues with memory, at least the numpy version let me know in a matter of second (&amp;lt; min).&amp;nbsp; I had looked at chunking it up with the options available in RasterToNumpyArray, and that would probably work, if I figure out the logic to find the lowerleft corners of each split...and that might still be an option.&amp;nbsp; I was playing areound with the SpitRaster command, but my first attempt was a disaster since I messed up the attributes.&amp;nbsp; Anyway, I appreciate the effort, and in the long run I'll probably use bits of all the suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 05:13:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339726#M26619</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-05-20T05:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339727#M26620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes it&amp;nbsp; is python version... split works too&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 10:22:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339727#M26620</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-20T10:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339728#M26621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The splitting of the array has solved the memory issues I believe.&amp;nbsp; FYI - for others that may see this, to make it a little more generic/robust for different size raster, I'm splitting it into 3 raster, based on&amp;nbsp; len(arr)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;...
arr = np.load(r"C:\___bear2016\_Skwentna2017\outras.npy")
# count number of elements so it can be split
arrCnt = len(arr)
arrSplit0 = int(arrCnt/3)
arrSplit1 = (int(arrCnt/3) * 2)
# now reclass in slices and stack back&amp;nbsp; 
arr_rc0 = arr_reclass(arr[:arrSplit0,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_rc1 = arr_reclass(arr[arrSplit0:arrSplit1,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_rc2 = arr_reclass(arr[arrSplit1:,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_stack = np.vstack((arr_rc0,arr_rc1, arr_rc2))&amp;nbsp; 
arr = arcpy.NumPyArrayToRaster(arr_stack) #, value_to_nodata=noDataReclass)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having an issue yet trying to save it back to the raster, but Dan, unless you or someone can see quickly what the issue is, I'll keep searching/testing an post another thread if necessary.&amp;nbsp; I'm not sure if it is a numpy issue or the arcpy issues on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...closing...will continure editing...&lt;/P&gt;&lt;P&gt;EDIT: last response was getting to slow, so closed and editing to complete response....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error message I'm getting&lt;/P&gt;&lt;P&gt;Runtime error &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 127, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\__init__.py", line 2292, in NumPyArrayToRaster&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _NumPyArrayToRaster(*args, **kwargs)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;TypeError: Cannot create raster for numpy array.&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have tried a few varieties...but now I may have to look at the no data.&amp;nbsp; I had set a nodata value, which should have handled it....but, need to look again..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339728#M26621</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T16:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339729#M26622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;quickly offhand, don't use arr as the variable name for output since it 'exists' try arr_out ... I will&amp;nbsp; check when on an arc machine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BACK&lt;/P&gt;&lt;P&gt;I just assembled a test using 3 arrays (floating point) and stacked them&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dan demos in python 3.4
Date...
&amp;gt;&amp;gt;&amp;gt; a_rc
array([[ 7.,&amp;nbsp; 6.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 8.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 8.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 4.,&amp;nbsp; 6.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 7.,&amp;nbsp; 7.,&amp;nbsp; 8.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 2.,&amp;nbsp; 1.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 3.,&amp;nbsp; 8.]])
&amp;gt;&amp;gt;&amp;gt; t = np.vstack((a_rc,a_rc,a_rc))
&amp;gt;&amp;gt;&amp;gt; t
array([[ 7.,&amp;nbsp; 6.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 8.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 7.,&amp;nbsp; 7.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 7.,&amp;nbsp; 7.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 8.,&amp;nbsp; 7., ...,&amp;nbsp; 8.,&amp;nbsp; 4.,&amp;nbsp; 6.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 8.,&amp;nbsp; 7.,&amp;nbsp; 7., ...,&amp;nbsp; 7.,&amp;nbsp; 7.,&amp;nbsp; 8.],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 2.,&amp;nbsp; 1.,&amp;nbsp; 8., ...,&amp;nbsp; 8.,&amp;nbsp; 3.,&amp;nbsp; 8.]])
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt; tt = arcpy.NumPyArrayToRaster(t)
&amp;gt;&amp;gt;&amp;gt; tt.save("f:/test/tt")
&amp;gt;&amp;gt;&amp;gt; t.ndim
2
&amp;gt;&amp;gt;&amp;gt; t.shape
(21000, 14000)
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;The results&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="array_vstack.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/201685_array_vstack.png" style="width: 620px; height: 440px;" /&gt;&lt;/P&gt;&lt;P&gt;Do note the size of the input arrays and the output raster.&amp;nbsp; I am just praying that the inability to save was due to the naming convention and that you don't have to save each raster, then&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/mosaic-to-new-raster.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/mosaic-to-new-raster.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Mosaic To New Raster—Help | ArcGIS for Desktop&lt;/A&gt; .&amp;nbsp; If it is a memory issue you will have to label the LL corner of each array, save it so that they can be merged inside of arcmap into a final array.&lt;/P&gt;&lt;P&gt;Rebecca... time to move to python 3.4 (at least) &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339729#M26622</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339730#M26623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just did some digging, python prior to 2.5 had the 2GB limit (even for 64 bit systems).&amp;nbsp; Numpy does not, there were some pretty ridiculously large files being read and used&lt;/P&gt;&lt;P&gt;see hpaulj's comment &lt;A href="http://stackoverflow.com/questions/37365064/memory-mapping-slows-down-over-time-alternatives" title="http://stackoverflow.com/questions/37365064/memory-mapping-slows-down-over-time-alternatives"&gt;http://stackoverflow.com/questions/37365064/memory-mapping-slows-down-over-time-alternatives&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plus there are alternatives&lt;/P&gt;&lt;P&gt; &lt;A href="http://stackoverflow.com/questions/26214696/creating-very-large-numpy-arrays-in-small-chunks-pytables-vs-numpy-memmap" title="http://stackoverflow.com/questions/26214696/creating-very-large-numpy-arrays-in-small-chunks-pytables-vs-numpy-memmap"&gt;http://stackoverflow.com/questions/26214696/creating-very-large-numpy-arrays-in-small-chunks-pytables-vs-numpy-memmap&lt;/A&gt; &lt;/P&gt;&lt;P&gt;h5py, pytables and Dask (haven't checked these all out yet, the first is best for simple single content arrays, the 2nd for tabular arrays, Dask is from Continuum, ) &lt;A href="http://dask.pydata.org/en/latest/array.html" title="http://dask.pydata.org/en/latest/array.html"&gt;Array — dask 0.9.0 documentation&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 May 2016 00:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339730#M26623</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-22T00:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339731#M26624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, I don't think the "arr" name itself the issue (since that made no difference), but I'm using a different array names just in case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am doing now is redefining each array as&amp;nbsp; "= []" as soon as I don't need it anymore, which seems to free up the space.&amp;nbsp; From a number of other discussions I've read thru, doing a "del array_variable" only deletes the variable and does not free up the memory.&amp;nbsp; (just an fyi for anyone reading&amp;nbsp; this).&amp;nbsp; So that help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next issues (not discovered or resolved in this order) were that I had to specify the lowerleft and the cell-size that I saved at the very beginning of my script from the original raster....I also had to use DefineProjection since that isn't an option in the NumPyArrayToRaster&amp;nbsp; (snippet of these lines below)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;np.save(r"C:\___bear2016\_Skwentna2017\outras.npy", arr)&amp;nbsp;&amp;nbsp; #save in binary format
arr = []
arrLoad = np.load(r"C:\___bear2016\_Skwentna2017\outras.npy")
# count number of elements so it can be split
arrCnt = len(arrLoad)
arrSplit0 = int(arrCnt/3)
arrSplit1 = (int(arrCnt/3) * 2)
# now reclass in slices and stack back&amp;nbsp; 
arr_rc0 = arr_reclass(arrLoad[:arrSplit0,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_rc1 = arr_reclass(arrLoad[arrSplit0:arrSplit1,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_rc2 = arr_reclass(arrLoad[arrSplit1:,:], bins=bins, new_bins=new_bins)&amp;nbsp; 
arr_stack = np.vstack((arr_rc0,arr_rc1, arr_rc2))&amp;nbsp; 
print(arr_stack.ndim)
print(arr_stack.shape)
arr_rc0 = []
arr_rc1 = []
arr_rc2 = []
print(lowerLeft)
newRas = arcpy.NumPyArrayToRaster(arr_stack, lowerLeft, cellSize)&amp;nbsp; 
newRas.save(outDEMtmp)&amp;nbsp; 
newRas = []
arcpy.DefineProjection_management(outDEMtmp, spatialref)
arcpy.RasterToPolygon_conversion(outDEMtmp, pElevClass, "SIMPLIFY", "Value")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, now the issue is that the RasterToPolygon does not see the outDEMtmp as a valid raster,&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="170" src="https://community.esri.com/legacyfs/online/201652_pastedImage_2.png" style="width: 321px; height: 169.94px;" width="321" /&gt;&lt;/P&gt;&lt;P&gt;even though it appears to be fine when displaying and/or looking at the properties.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" height="272" src="https://community.esri.com/legacyfs/online/201722_pastedImage_3.png" style="width: 362px; height: 272.08px;" width="362" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the error in the python window (which I tried first)&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.RasterToPolygon_conversion(outDEMtmp, pElevClass, "SIMPLIFY", "Value")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39; font-size: 10pt;"&gt;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&amp;nbsp;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 337, in RasterToPolygon&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e ExecuteError: ERROR 000864: Input raster: The input is not within the defined domain. ERROR 000367: Invalid GP data type&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Neither of the error seems to be relevant. A restart didn't help....so on to researching this.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...maybe I'll copy to a new raster, if that works.&amp;nbsp; Any chance the NumPyToRaster doesn't work quite right??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339731#M26624</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T16:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: reclassify using Numpy, out of memory</title>
      <link>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339732#M26625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;del delete the reference and cleans it up... &lt;STRONG&gt;if&lt;/STRONG&gt; it is only being used by python and not any other software maybe like arcmap or a geodatabase being used in arcmap if the source or destination is one...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No...I ran tests today and got a valid rasters and huge ones as you can see.&amp;nbsp; The issue isn't with numpy, NumPyToRaster produces a valid raster.&amp;nbsp; The only thing you did different is that you defined a coordinate system... don't, just convert it to a polygon, save your work, then see if you can define the projection.&amp;nbsp; If you are doing this in a geodatabase... move it outside of a geodatabase...make an esri grid in a folder, make a shapefile in a folder, I want to rule out this whole geodatabase thing and its clutches and clucking on everything that is done.&amp;nbsp; You can always copy stuff back into one, I just want to work with native operating stuff first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now... as for the results. Are you planning to mix the results with other data? if so, then you will need the projected featureclass/shapefile, it is not needed for the raster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;keep me posted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 May 2016 02:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reclassify-using-numpy-out-of-memory/m-p/339732#M26625</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-22T02:34:28Z</dc:date>
    </item>
  </channel>
</rss>

