<?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: Python Won't Run Spatial Autocorrelation Script Twice in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135870#M10673</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have an error also regarding spatial autocorrelation (moran;s I):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Executing: SpatialAutocorrelation calculationdepth FID_tmhous NO_REPORT INVERSE_DISTANCE EUCLIDEAN_DISTANCE NONE # #&lt;/P&gt;&lt;P&gt;Start Time: Tue Jul 08 15:35:41 2014&lt;/P&gt;&lt;P&gt;Running script SpatialAutocorrelation...&lt;/P&gt;&lt;P&gt;WARNING 000853: The default neighborhood search threshold was 7349.512418 Meters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 610, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; setupGlobalI()&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 88, in setupGlobalI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; threshold = threshold, exponent = exponent)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 157, in __init__&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.construct()&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 361, in construct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nhVals, weights)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 405, in processRow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.wij[ij] = w&lt;/P&gt;&lt;P&gt;MemoryError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (SpatialAutocorrelation).&lt;/P&gt;&lt;P&gt;Failed at Tue Jul 08 15:36:01 2014 (Elapsed Time: 20.00 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i already looked the same error in the internet but nobody tried to answer this question (from other people)..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i hope someone could help me...-.- please &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2014 06:46:26 GMT</pubDate>
    <dc:creator>ImeeNecesito</dc:creator>
    <dc:date>2014-07-08T06:46:26Z</dc:date>
    <item>
      <title>Python Won't Run Spatial Autocorrelation Script Twice</title>
      <link>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135868#M10671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to calculate a Global Moran's I statistic on a [long] list of point files using python.&amp;nbsp; I have set up my code to loop through the arcpy.SpatialAutocorrelation_stats script as shown below.&amp;nbsp; The loop runs through the first shapefile without a problem and prints out the Moran's I Summary Table.&amp;nbsp; When it gets to the second shapefile, it crashes with a strange error.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can manually run the Spatial Autocorrelation Script in batch form without a problem from ArcCatalog.&amp;nbsp; However, I don't want to parse through the Results window later.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS 10.1 with Python XY (Spyder) 2.7 on a Windows 7 64-bit machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone encountered this error or found any solutions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
dataPath = r"c:\data"
elevationPoints = ["elevPts1.shp", "elevPts2.shp"]
elevationPoints = ["id_1pt.shp","id_11pt.shp"]
dataPath = r"C:\Users\Andy\Desktop\BlackbirdKnob_WV\tempPts"
for i in range(len(elevationPoints)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SpatialAutocorrelation_stats (dataPath+"\\"+elevationPoints&lt;I&gt;, "GRID_CODE", "NO_REPORT" , "FIXED_DISTANCE_BAND", "EUCLIDEAN_DISTANCE" ,"NONE","15")
&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the error message that comes up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Traceback (most recent call last):
&amp;nbsp; File "C:\Users\Andy\Desktop\MoransLoop.py", line 20, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SpatialAutocorrelation_stats (dataPath+"\\"+elevationPoints&lt;I&gt;, "GRID_CODE", "NO_REPORT" , "FIXED_DISTANCE_BAND", "EUCLIDEAN_DISTANCE" ,"NONE","15")
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\stats.py", line 403, in SpatialAutocorrelation
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
arcgisscripting.ExecuteError: 
Traceback (most recent call last):
&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 21, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import SSReport as REPORT
&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.1\ArcToolbox\Scripts\SSReport.py", line 17, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import pylab as PYLAB
&amp;nbsp; File "C:\Python27\lib\site-packages\pylab.py", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from matplotlib.pylab import *
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 264, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from matplotlib.pyplot import *
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 23, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from matplotlib.figure import Figure, figaspect
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 18, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from axes import Axes, SubplotBase, subplot_class_factory
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 338, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; class Axes(martist.Artist):
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 2051, in Axes
&amp;nbsp;&amp;nbsp;&amp;nbsp; def grid(self, b=None, which='major', axis='both', **kwargs):
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\docstring.py", line 103, in dedent_interpd
&amp;nbsp;&amp;nbsp;&amp;nbsp; return interpd(dedent(func))
&amp;nbsp; File "C:\Python27\lib\site-packages\matplotlib\docstring.py", line 36, in __call__
&amp;nbsp;&amp;nbsp;&amp;nbsp; func.__doc__ = func.__doc__ and func.__doc__ % self.params
KeyError: 'Line2D'

Failed to execute (SpatialAutocorrelation).
&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 17:38:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135868#M10671</guid>
      <dc:creator>AndrewStauffer1</dc:creator>
      <dc:date>2012-10-09T17:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Python Won't Run Spatial Autocorrelation Script Twice</title>
      <link>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135869#M10672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found a temporary fix.&amp;nbsp; Since it seems that the the first few errors were being derived from the MoransI.py module within the SpatialAutocorrelation_stat tool, it was re-loaded in the script with hopes that it would resolve the problem.&amp;nbsp; It worked, but is still a bit of an odd work-around.&amp;nbsp; See the below code that allowed the Spatial Autocorrelation tool to be iteratively executed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
arcpy.env.overwriteOutput
dataPath = r"c:\data"
elevationPoints = ["elevPts1.shp", "elevPts2.shp"]
for i in range(len(elevationPoints)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; import MoransI
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SpatialAutocorrelation_stats (dataPath+"\\"+elevationPoints&lt;I&gt;, "GRID_CODE", "#" , "FIXED_DISTANCE_BAND", "EUCLIDEAN_DISTANCE" ,"NONE","15")

&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:34:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135869#M10672</guid>
      <dc:creator>AndrewStauffer1</dc:creator>
      <dc:date>2021-12-11T07:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Won't Run Spatial Autocorrelation Script Twice</title>
      <link>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135870#M10673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have an error also regarding spatial autocorrelation (moran;s I):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Executing: SpatialAutocorrelation calculationdepth FID_tmhous NO_REPORT INVERSE_DISTANCE EUCLIDEAN_DISTANCE NONE # #&lt;/P&gt;&lt;P&gt;Start Time: Tue Jul 08 15:35:41 2014&lt;/P&gt;&lt;P&gt;Running script SpatialAutocorrelation...&lt;/P&gt;&lt;P&gt;WARNING 000853: The default neighborhood search threshold was 7349.512418 Meters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 610, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; setupGlobalI()&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 88, in setupGlobalI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; threshold = threshold, exponent = exponent)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 157, in __init__&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.construct()&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 361, in construct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nhVals, weights)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.1\ArcToolbox\Scripts\MoransI.py", line 405, in processRow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.wij[ij] = w&lt;/P&gt;&lt;P&gt;MemoryError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (SpatialAutocorrelation).&lt;/P&gt;&lt;P&gt;Failed at Tue Jul 08 15:36:01 2014 (Elapsed Time: 20.00 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i already looked the same error in the internet but nobody tried to answer this question (from other people)..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i hope someone could help me...-.- please &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 06:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-won-t-run-spatial-autocorrelation-script/m-p/135870#M10673</guid>
      <dc:creator>ImeeNecesito</dc:creator>
      <dc:date>2014-07-08T06:46:26Z</dc:date>
    </item>
  </channel>
</rss>

