Использование этого руководства - https://pro.arcgis.com/en/pro-app/tool-reference/spatial-statistics/convert-spatial-weights-matrix-to-table.htm
# Create a Spatial Weights Matrix based on Shapefile
# Import system modules
import arcpy
# Set property to overwrite existing output
arcpy.arcpy.overwriteOutput = True
try:
# Create Spatial Weights Matrix
# Process: Generate Spatial Weights Matrix...
swm = arcpy.GenerateSpatialWeightsMatrix_stats("SHAPE.shp", "OBJECTID",
"SWM.swm",
"K_NEAREST_NEIGHBORS",
"#", "#", "#", 6)
# Dump Spatial Weights to Database Table
# Process: Convert Spatial Weights Matrix to Table...
dbf = arcpy.ConvertSpatialWeightsMatrixtoTable_stats("SWM.swm",
"DBF.dbf")
except arcpy.ExecuteError:
# If an error occurred when running the tool, print out the error message.
print(arcpy.GetMessages())
Я уже загрузил шейп-файл и запустил приведенный выше код, который создает файл swm, а затем преобразует его в dbf. Затем я меняю вес на то, что я хочу. Эта часть работает отлично.
Даже если я не пытаюсь изменить какие-либо значения и конвертировать обратно в SWM, я получаю ошибку. Эта проблема возникает при попытке преобразовать обратно из dbf в swm (используя python в arcMAP) с помощью приведенного ниже сценария.
# Create a Spatial Weights Matrix based on Database File
# Import system modules
import arcpy
# Set property to overwrite existing output
arcpy.arcpy.overwriteOutput = True
try:
swm = arcpy.GenerateSpatialWeightsMatrix_stats("SHAPE.shp", "OBJECTID",
"SWM2.swm",
"CONVERT_TABLE",
"#", "#", "#",
"#", "#", "#",
"DBF.dbf")
except arcpy.ExecuteError:
# If an error occurred when running the tool, print out the error message.
print(arcpy.GetMessages())
Я получаю следующее сообщение об ошибке
Executing: GenerateSpatialWeightsMatrix SWM2.swm CONVERT_TABLE EUCLIDEAN 1 # # ROW_STANDARDIZATION # DBF.dbf # #
Start Time: Thu Oct 10 12:18:13 2019
Failed to execute. Parameters are not valid.
ERROR 000308: Invalid field type
Failed to execute (GenerateSpatialWeightsMatrix).
Failed at Thu Oct 10 12:18:23 2019 (Elapsed Time: 10.14 seconds)