ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Convert Spatial Weights Matrix to Table

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

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

Illustration

Swm to DBF conversion
Swm files may be converted to .dbf tables and edited.

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 or Generate Network Spatial Weight 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

arcpy.stats.ConvertSpatialWeightsMatrixtoTable(Input_Spatial_Weights_Matrix_File, Output_Table)
ParameterExplanationData 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

ConvertSpatialWeightsMatrixtoTable example 1 (Python window)

The following Python Window script demonstrates how to use the ConvertSpatialWeightsMatrixtoTable function.

import arcpy
arcpy.env.workspace = "c:/data"
arcpy.ConvertSpatialWeightsMatrixtoTable_stats("euclidean6Neighs.swm", "euclidean6Neighs.dbf")
ConvertSpatialWeightsMatrixtoTable example 2 (stand-alone script)

The following stand-alone Python script demonstrates how to use the ConvertSpatialWeightsMatrixtoTable function.

# Create a Spatial Weights Matrix based on Network Data 

# Import system modules
import arcpy

# Set property to overwrite existing output
arcpy.env.overwriteOutput = True

# Local variables...
workspace = r"C:\Data\USCounties\US"

# 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")

Environments

  • Current Workspace
  • Scratch Workspace

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics

  • An overview of the Utilities toolset
  • Generate Spatial Weights Matrix
  • Generate Network Spatial Weights
  • Modeling spatial relationships
  • Spatial Autocorrelation (Global Moran's I)
  • High/Low Clustering (Getis-Ord General G)
  • Cluster and Outlier Analysis (Anselin Local Moran's I)
  • Hot Spot Analysis (Getis-Ord Gi*)

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal