## Summary

Converts a binary spatial weights matrix file (.swm) to a table.

## Illustration

## Usage

This tool allows you to edit a spatial weights matrix file, if necessary:

- Create a spatial weights matrix file using the Generate Spatial Weights Matrix tool.
- Convert the resultant spatial weights matrix file to a table using this tool.
- Edit the table and modify the spatial relationships as desired.
- Use the Generate Spatial Weights Matrix tool to convert the modified table back to the binary spatial weights matrix file format.

## Syntax

ConvertSpatialWeightsMatrixtoTable_stats (Input_Spatial_Weights_Matrix_File, Output_Table)

Parameter | Explanation | Data Type |

Input_Spatial_Weights_Matrix_File | The full pathname for the spatial weights matrix file (.swm) you want to convert. | File |

Output_Table | A full pathname to the table you want to create. | Table |

## Code sample

The following Python Window script demonstrates how to use the Convert Spatial Weights Matrix to Table tool.

```
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.ConvertSpatialWeightsMatrixtoTable_stats("euclidean6Neighs.swm","euclidean6Neighs.dbf")
```

The following stand-alone Python script demonstrates how to use the Convert Spatial Weights Matrix to Table tool.

```
# Create a Spatial Weights Matrix based on Network Data
# Import system modules
import arcpy
# Set property to overwrite existing output
arcpy.arcpy.overwriteOutput = True
# Local variables...
workspace = r"C:\Data\USCounties\US"
try:
# Set the current workspace (to avoid having to specify the full path to the feature classes each time)
arcpy.env.workspace = workspace
# Create Spatial Weights Matrix
# Process: Generate Spatial Weights Matrix...
swm = arcpy.GenerateSpatialWeightsMatrix_stats("USCounties.shp", "MYID",
"euclidean6Neighs.swm",
"K_NEAREST_NEIGHBORS",
"#", "#", "#", 6)
# Dump Spatial Weights to Database Table
# Process: Convert Spatial Weights Matrix to Table...
dbf = arcpy.ConvertSpatialWeightsMatrixtoTable_stats("euclidean6Neighs.swm",
"euclidean6Neighs.dbf")
# Now you can edit the spatial weights (add, subtract and alter
# neighbors and weights)
# Read weights from table back into Spatial Weights Matrix format
# Process: Generate Spatial Weights Matrix...
swm = arcpy.GenerateSpatialWeightsMatrix_stats("USCounties.shp", "MYID",
"euclidean6Neighs.swm",
"CONVERT_TABLE",
"#", "#", "#",
"#", "#", "#",
"euclidean6Neighs.dbf")
except arcpy.ExecuteError:
# If an error occurred when running the tool, print out the error message.
print(arcpy.GetMessages())
```

## Environments

## Licensing information

- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes