<?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: sa.Sample Performance in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28138#M366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I started a test run with the ExtractMultiValuesToPoints method --- going on 5hrs now and my trigger finger is itching to kill the process as it is worse than sa.Sample at this point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any input is appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;j&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Mar 2014 16:26:52 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2014-03-03T16:26:52Z</dc:date>
    <item>
      <title>sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28137#M365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am invoking arcpy.sa.Sample() method on 540 individual rasters in a FGDB using a point feature class in the same workspace that contains 50 points.&amp;nbsp; S-L-O-W is the word.&amp;nbsp; Alternatives that have better performance?&amp;nbsp; (prelim testing with ExtractMultiValuesToPoints doesn't offer any better performance).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The 540 rasters I am processing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;236 cols&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;552 rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2400, 2400 cellsize&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Point FC has 50 points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It take about 3 hours to generate an output result and I need to drastically reduce this.&amp;nbsp; Non-ESRI solutions are acceptable!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 13:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28137#M365</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-03T13:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28138#M366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I started a test run with the ExtractMultiValuesToPoints method --- going on 5hrs now and my trigger finger is itching to kill the process as it is worse than sa.Sample at this point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any input is appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;j&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 16:26:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28138#M366</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-03T16:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28139#M367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This raster is pretty small. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are at 10.1 or later, have you considered copying it to the in_memory workspace and seeing if that runs faster (I would expect it too, though you may have to try the different sampling tools to see which one works best.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 14:14:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28139#M367</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-03-04T14:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28140#M368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This raster is pretty small. &lt;BR /&gt;&lt;BR /&gt;If you are at 10.1 or later, have you considered copying it to the in_memory workspace and seeing if that runs faster (I would expect it too, though you may have to try the different sampling tools to see which one works best.)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Curt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd have to copy the whole set of 540 rasters into in_memory.&amp;nbsp; Not adverse to that, and I will give it a go!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 16:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28140#M368</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-04T16:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28141#M369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming 32bit values, you're still only looking at something like 268MB (236*552*540*4 bytes) of data, which should fit into memory without a problem. Doing that for both your rasters and points would be a good place to start as Curtis mentions, as your sampling has to iterate over all points and rasters which isn't particularly fast. Another option that would take more work is to stack the rasters using multidimensional arrays, such as with NumPy or NetCDF. Then, you can pull out the values of all 540 rasters by sampling a single vector (all rasters at one point) which should greatly improve performance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Shaun&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 18:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28141#M369</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2014-03-06T18:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28142#M370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;James,&lt;BR /&gt;&lt;BR /&gt;Assuming 32bit values, you're still only looking at something like 268MB (236*552*540*4 bytes) of data, which should fit into memory without a problem. Doing that for both your rasters and points would be a good place to start as Curtis mentions, as your sampling has to iterate over all points and rasters which isn't particularly fast. Another option that would take more work is to stack the rasters using multidimensional arrays, such as with NumPy or NetCDF. Then, you can pull out the values of all 540 rasters by sampling a single vector (all rasters at one point) which should greatly improve performance.&lt;BR /&gt;&lt;BR /&gt;cheers,&lt;BR /&gt;Shaun&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm all ears.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you provide just a tad more guidance on this?&amp;nbsp; What would the approach look like?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Loop all 540 and convert to a list of numpy arrays &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

rasterarray = []
arcount = 1
for conraster in concrasters:
&amp;nbsp;&amp;nbsp; rasArray = "rasArray" + str(arcount)
&amp;nbsp;&amp;nbsp; rasArray = arcpy.RasterToNumPyArray(conraster)
&amp;nbsp;&amp;nbsp; rasterarray.append(rasArray)
&amp;nbsp;&amp;nbsp; arcount = arcount + 1

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Sample with my input polyine.&amp;nbsp; I am not exactly sure of the options here.&amp;nbsp; Suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:08:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28142#M370</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-10T21:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28143#M371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This sounds like a great idea. NumPy arrays stored in my experience very efficiently, so if you have zero's/nodata etc you probably will be just fine memory wise.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Sample with my input polyline.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You'd have to convert your line to points and then convert the points to numpy row-col coordinates using basic geometric arithmetic against your extent and cell size.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 16:31:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28143#M371</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-03-12T16:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: sa.Sample Performance</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28144#M372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This sounds like a great idea. NumPy arrays stored in my experience very efficiently, so if you have zero's/nodata etc you probably will be just fine memory wise.&lt;BR /&gt;&lt;BR /&gt;You'd have to convert your line to points and then convert the points to numpy row-col coordinates using basic geometric arithmetic against your extent and cell size.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your input, Curtis.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So if I have converted my rasters to a list of numpy arrays and my polyline as a numpy row/col array too, what do you envision as the next step?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 11:55:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/sa-sample-performance/m-p/28144#M372</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-17T11:55:52Z</dc:date>
    </item>
  </channel>
</rss>

