Generate Spatial Weights Matrix error in ArcGIS 10.2

5601
4
03-28-2014 04:56 PM
FranciscoGoerlich
New Contributor
I have been unable to run the Generate Spatial Weights Matrix in ArcGIS 10.2.
I always get the same error:

Executing: GenerateSpatialWeightsMatrix D:\GIS\CNIG\Equipamiento_Geográfico_Referencia_Nacional\lineas_limite_2011Mayo\ETRS89_LAEA\Municipios2006_ETRS89_LAEA.shp INENumMuni D:\GIS\CNIG\Equipamiento_Geográfico_Referencia_Nacional\lineas_limite_2011Mayo\ETRS89_LAEA\Municipios2006_ETRS89_LAEA.swm CONTIGUITY_EDGES_CORNERS EUCLIDEAN 1 # 0 NO_STANDARDIZATION # # # #
Start Time: Sat Mar 29 01:42:52 2014
Running script GenerateSpatialWeightsMatrix...
Constructing spatial weights based on polygon contiguity (Edges or Corners)....

Traceback (most recent call last):
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 910, in <module>
    setupWeights()
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 110, in setupWeights
    contiguityType = "QUEEN")
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 201, in polygon2SWM
    numNeighs = kNeighs)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts\WeightsUtilities.py", line 203, in __init__
    self.setHeader()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts\WeightsUtilities.py", line 261, in setHeader
    header = NUM.array([header], '<c')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128)

Failed to execute (GenerateSpatialWeightsMatrix).
Failed at Sat Mar 29 01:43:24 2014 (Elapsed Time: 31.68 seconds)

I am not sure if this is an error from ArcGIS or a configuration error with Python.

Thanks in advance for any help.
0 Kudos
4 Replies
ShaunWalbridge
Esri Regular Contributor
Goerlich,

It looks like that particular tool has a bug in how it handles Unicode characters beyond the base 7-bit ASCII set. In particular, it is failing on the 'á' character, or 0x1E in hexadecimal. It looks like that character is included in one of your paths, could you try running the script from a directory which only has plain characters in its name? This is a bug, and should be filed as such, but this will at least get you up and running for the time being.

cheers,
Shaun
0 Kudos
FranciscoGoerlich
New Contributor
Shaun,
You are right!
Since I am using Canopy 1.3.0 (which uses Python 2.7.6 with Numpy 1.8.0 and matplotlib 1.3.1 instead of Numpy 1.6.1 and matplotlib 1.1.1 which is used by the Python 2.7.3 that comes with ArcGIS 10.2) I thought it was an incompatibility problem somewhere.

But you may see the "á" in my path, and removing this has solved the problem.

Many thanks,
0 Kudos
calosteward
New Contributor

Thank you, Francisco

Your work also give me some guides on solving matrix generation error.

I'm really appreciate you.

Best regards.

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Note that this issue is now solved at ArcGIS 10.3 or later, and in ArcGIS Pro.

0 Kudos