<?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: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91560#M7128</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I've been practicing recently with numpy for certain tasks.&amp;nbsp; It works nicely (using indices) for returning the row and column numbers for small and medium-sized rasters, up to a few thousand cells on a side.&amp;nbsp; When I work with large rasters (10000-by-10000 or larger), I get a Python Memory Error.&amp;nbsp; It seems that numpy is not an option for doing computations with data for large rasters.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out &lt;/SPAN&gt;&lt;A href="http://www.pytables.org/moin" rel="nofollow noopener noreferrer" target="_blank"&gt;pytables&lt;/A&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;A href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html" rel="nofollow noopener noreferrer" target="_blank"&gt;numpy.memmap&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a practical procedure out there for returning row and column numbers for large rasters?&amp;nbsp; I've seen suggestions for using fishnet or flowaccumulation, but am guessing that the steps involved would make for verrry slow processing.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3) #This works in ArcGIS 10 for backwards compatibility.
#Make sure extent and cellsize are set in the arcgisscripting environment...
expr='$$rowmap'
output=r'C;\Temp\rowmap'
result=gp.SingleOutputMapAlgebra(expr,output)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:30:07 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2021-12-10T23:30:07Z</dc:date>
    <item>
      <title>Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91557#M7125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been practicing recently with numpy for certain tasks.&amp;nbsp; It works nicely (using indices) for returning the row and column numbers for small and medium-sized rasters, up to a few thousand cells on a side.&amp;nbsp; When I work with large rasters (10000-by-10000 or larger), I get a Python Memory Error.&amp;nbsp; It seems that numpy is not an option for doing computations with data for large rasters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(I'm running ArcGis 10 experimentally on a Windows Server 2008 machine, 64-bit, with supposedly 48 GB of RAM.&amp;nbsp; Yes, I understand that by my definition a large raster could take up several GB when held in memory.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a practical procedure out there for returning row and column numbers for large rasters?&amp;nbsp; I've seen suggestions for using fishnet or flowaccumulation, but am guessing that the steps involved would make for verrry slow processing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also running into precision problems when working with large numbers in Map Algebra.&amp;nbsp; Integer arithmetic works nicely up to 2^31 (about 2 billion), but I have to go to floating-point for larger numbers.&amp;nbsp; Computations involving large numbers, such as sums of squares, begin to lose accuracy and produce unacceptable artifacts in the output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can get around the precision problems in Map Algebra by converting my raster objects to numpy arrays and defining them as float64.&amp;nbsp; However, as the rasters get larger, then I run into the memory errors again.&amp;nbsp; For example, if I have a 5000-by-5000 raster, I can't keep more than about three variables (as numpy arrays) in play without getting memory errors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running calculations on data in numpy arrays is very fast, I suppose because everything is held in memory.&amp;nbsp; The limits to that memory, however, render "the numpy route" unusable for working with larger rasters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like the new Map Algebra, but what was ESRI thinking when they decided to give us this set of "features"?&amp;nbsp; Please give us back $$rowmap and $$colmap.&amp;nbsp; Please let us define rasters to have higher levels of precison.&amp;nbsp; Please give us a supplemental programming option that lets us handle large rasters (arrays).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently my only option is to write programs that won't work for large rasters.&amp;nbsp; Because I do a lot of work with LiDAR-based elevation data, that's not much of an option.&amp;nbsp; Does anyone have workarounds for these issues?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, Tim.L&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 13:57:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91557#M7125</guid>
      <dc:creator>deleted-user-De598MZ4-kwO</dc:creator>
      <dc:date>2011-11-30T13:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91558#M7126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll have to forgive my ignorance with rasters in arcpy, I am new to arc stuff, coming from mostly open source gis.&amp;nbsp; I have a few questions/comments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* What is the scope of your task?&amp;nbsp; Are you just doing calculations on the raster data, or are you using some other functionality?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;* Can you 'tile' your raster and still achieve your goal?&amp;nbsp; Meaning if you read in 512 rows x 512 columns starting from the origin, iterating over the 'blocks' or 'tiles'?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Comments:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* You can't read any raster over 2 gb in arcpy, it is a 32 bit process.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;* If you don't need to do it in arc, try using gdal python bindings, see gdal.org&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;* I would have to look at the precision issues separately.&amp;nbsp; Not sure about that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 14:44:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91558#M7126</guid>
      <dc:creator>KyleShannon</dc:creator>
      <dc:date>2011-11-30T14:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91559#M7127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm doing a lot of calculations based on elevation values.&amp;nbsp; The current problem involves alternative methods for calculating and manipulating slope and aspect and derivative products, but that's not the point now.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could tile the datasets into smaller pieces, and maybe will have to do that if no other method presents itself, but that's an inelegant and unsatisfactory solution.&amp;nbsp; Because of edge effects, the tiles would need to overlap, and then the overlaps would need to be removed when joining the processed tiles back together.&amp;nbsp; It could be automated, and perhaps someone else has already written a script to do that, but I'm looking for a better and more fundmental answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to use the ESRI geoprocessor and related available tools, without the user needing to install anything extra.&amp;nbsp; All of our GIS work is done in the ESRI environment.&amp;nbsp; One good reason for staying with SA is the ease in making calculations based on movng (running) windows, such as focal stats and kernels.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't see any way around the precision problem for large rasters, with the current version of ArcGis.&amp;nbsp; Map Algebra can handle large rasters (albeit slowly), and Python/numpy can handle high-precision numbers, but I don't have a way to handle both at the same time.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 15:48:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91559#M7127</guid>
      <dc:creator>deleted-user-De598MZ4-kwO</dc:creator>
      <dc:date>2011-11-30T15:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91560#M7128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I've been practicing recently with numpy for certain tasks.&amp;nbsp; It works nicely (using indices) for returning the row and column numbers for small and medium-sized rasters, up to a few thousand cells on a side.&amp;nbsp; When I work with large rasters (10000-by-10000 or larger), I get a Python Memory Error.&amp;nbsp; It seems that numpy is not an option for doing computations with data for large rasters.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out &lt;/SPAN&gt;&lt;A href="http://www.pytables.org/moin" rel="nofollow noopener noreferrer" target="_blank"&gt;pytables&lt;/A&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;A href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html" rel="nofollow noopener noreferrer" target="_blank"&gt;numpy.memmap&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a practical procedure out there for returning row and column numbers for large rasters?&amp;nbsp; I've seen suggestions for using fishnet or flowaccumulation, but am guessing that the steps involved would make for verrry slow processing.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3) #This works in ArcGIS 10 for backwards compatibility.
#Make sure extent and cellsize are set in the arcgisscripting environment...
expr='$$rowmap'
output=r'C;\Temp\rowmap'
result=gp.SingleOutputMapAlgebra(expr,output)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91560#M7128</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-10T23:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91561#M7129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See my post for a method to get to $$ROWMAP using the unsupported back door to MOMA in 10.0. (Hi Tim!!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[thread]45087[/thread]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for the 32-bit precision issue - you are kind of stuck there as the tools were all written to work on grid floats (32-bit). Putting a raster into a high-precision raster stored in the file geodatabase may help somewhat (because of the new direct read/write at 10.0) - but probably only for some tools. Can your numpy arrays get bigger than 4GB? I would think they'd be limited by the fact that you need to use 32-bit python with ArcGIS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To do what you want effectively you may have to resort to what ESRI does with large data sets (vector and raster) -- tile your data (you could merge the results back together with&amp;nbsp; Mosaic pretty easily).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 18:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91561#M7129</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-12-02T18:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with large rasters: $$rowmap, numpy, Memory Error, and numeric precision</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91562#M7130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;nbsp;&amp;nbsp; Because of edge effects, the tiles would need to overlap, and then the overlaps would need to be removed when joining the processed tiles back together.&amp;nbsp; It could be automated, and perhaps someone else has already written a script to do that&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should be noted that the Mosaic tool (and mosaic data sets on the fly) can handle the stitching back together with averaging overlapping areas. Splitting apart, well, we still need a script for that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Feb 2012 00:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-large-rasters-rowmap-numpy-memory/m-p/91562#M7130</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-02-25T00:10:50Z</dc:date>
    </item>
  </channel>
</rss>

