chrisweston11

Converting my .dbf to a Spatial Weights Matrix .swm

Discussion created by chrisweston11 on Sep 19, 2011
Latest reply on Sep 20, 2011 by chrisweston11
Hello,

I have successfully used Python script to convert my .swm file to a .dbf, but I have not been able to convert the .dbf [after adjusting my weights] back to something that can read by ArcGIS, such as a .txt or .swm.  When I created the .swm file with my Input .shp, I declared the Unique ID as  "Data_ID" from the Input .shp.  I had to create this unique field in spite of the fact that the Input .shp already had FID.  This is an example of my .dbf output from the .swm.

Field1   Data_ID  NID  WEIGHT
0           1            2      1.000
0           2            3      1.000
0           3            4      0.333
0           3            2      0.333
0           4            5      0.500  

I thought it was strange that the "Field1" field was present with the 0 values.  I deleted this field given that it appeared to have no logical purpose, and it is not a field on my Input .shp.  That left me with the 2nd, 3rd, and 4th columns.  The Unique ID field in the Input .shp is of "short" data type.  I noticed that Microsoft Excel defaults the Data_ID field in my .dbf to "double" data type.  This would likely cause problems due to incoherent data types (short versus double).  I tried saving my .dbf as text(tab delimited) and also as a .csv file, but I received toolbox errors when trying to generate a new Spatial Weights Matrix.  These errors also happen when trying to import the .txt or .csv as the SWM table for Local Moran.

The ArcToolbox error that I keep seeing when I try to generate a .swm with my .dbf is that my table's Unique ID field does not match the Input Feature's Unique ID.  According to me, they do match.  However, the data type problem might persist due to the fact that the Input .shp Unique ID is "short" integer.  A text file might be able to bypass this data type issue.  Toolbox has also told me on a few attempts that it cannot locate my Unique ID field, but I know that my Unique ID is the same on both the Input .shp and the various files that I have tried to import during generation.

I think that my specific question is, "what do I need to do with my initial .dbf so that I can (after adjusting my weights) generate a new .swm?"

Thanks for your help,

Chris

Outcomes