POST
|
If you are trying to personalize your spatial weights matrix so that you can modify adjacency relationships (i.e. to modify LISA satistics) here is how you do it. Perform the usual spatial weights matrix generation with Spatial Statistics tool. Run the following Python script (you'll have some cleanup to do after pasting this) in the embedded Python window to create a seperate .dbf that represents your spatial weights relationships. The file paths below are as they are on my cpu; adjust them for your cpu. My .swm file was called "invasive_spatilweightsmatrix", as you can see. >>> import arcpy ... arcpy.env.workspace = "c:/thesis/spatial weights matrices/invasive_spatialweightsmatrix" ... arcpy.ConvertSpatialWeightsMatrixtoTable_stats("invasive_spatialweightsmatrix.swm","invasive_spatialweightsmatrix.dbf") ... After you do this, rightclick/export the file that gets added to your ArcGIS Table of Contents. Export it as a .dbf file. Then add the .dbf file (that you created in the previous step) to your ArcGIS Table of Contents, and open it. Delete any columns other than the following four fields: OID, "Unique ID Field", NID, and WEIGHT. I had to delete a field called "Field1". You will be left with four columns: OID, "UNIQUE ID FIELD", NID, and WEIGHT. Start the Editor and manually change the weights as you want them to be. This is the "dirty" part of the job, assuming you have to hunt down each feature weight that you want to modify. Save your edits and stop editor. Generate a new spatial weights matrix with the Convert_Table option in the Spatial Statistics Toolkit. Select your newly saved .dbf as the Input Table. ***Important, if your original .swm was created with row standardization, then you should NOT select row standardization when you create your new .swm in this current step. Your Input Table would already be row standardized if you selected row standardized in the initial creation of your .swm. You will undo any of your weight adjustments if you check that box during this current step.*** Now you can select this new .swm for runs in Local Moran or anything that is derived from a spatial weights matrix table and gives you the option of selecting a .swm file (in ArcGIS anyways). This was much easier than I made it out to be. I just threw a few extra details in for anybody who might need them. Good luck, Chris Weston
... View more
09-21-2011
12:19 AM
|
0
|
1
|
1228
|
POST
|
Okay, I figured it out. Read the above thread entitled "How to convert .dbf to a spatial weights matrix" -Chris
... View more
09-20-2011
11:39 PM
|
0
|
0
|
276
|
POST
|
More info....this is the error code that I get when trying to generate a new .swm. ERROR 000722: Could not read input spatial weights table due to conflict with the field names This baffles me since the Unique Id from the Input .shp is also on the file I'm using as the table for the .swm generation.
... View more
09-19-2011
09:20 PM
|
0
|
0
|
276
|
POST
|
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
... View more
09-19-2011
08:43 PM
|
0
|
2
|
608
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|