[R-sig-Geo] polygon identifiers and nb classes
Larry Layne
ljlayne at unm.edu
Wed Apr 19 16:02:50 CEST 2006
Hello Roger,
> Here is a first cut, which seems to emit a suitable file. If you can try
> it and/or send back an Arc command line say for COLUMBUS.SHP CRIME and
> NEIGNO as index in GeoDa, I would be grateful:
I'm not exactly sure what "as index in GeoDa" means but I have successfully
tested your code on 2 different data sets: my own and the columbus.shp
shapefile. Here is the full code to create the text file of spatial weights
in the form that ArcGIS wants them. The columbus shapefile is used as the
example file here:
library(maptools)
library(maps)
library(spdep)
setwd("E:\\ShapeFiles")
getwd()
COLUMBUSmap <- read.shape("columbus.shp")
COLUMBUSpolylist <- Map2poly(COLUMBUSmap,region.id=NULL,quiet=TRUE)
COLUMBUSnb <- poly2nb(COLUMBUSpolylist,row.names="POLYID",queen=FALSE)
print(is.symmetric.nb(COLUMBUSnb))
write.sn2Arc(listw2sn(nb2listw(COLUMBUSnb,style="B")),file="E://Shapefiles//zweights_test.txt",field="POLYID")
The tests were successful using style="B" or style="W".
Following are 2 Arc command lines, one for CRIME and the other for NEIGNO:
SpatialAutocorrelation columbus CRIME false "Get Spatial Weights From File"
"Euclidean Distance" None 0 E:\Shapefiles\zweights_test.txt 0 0
SpatialAutocorrelation columbus NEIGNO false "Get Spatial Weights From
File" "Euclidean Distance" None 0 E:\Shapefiles\zweights_test.txt 0 0
Thanks for the effort you put into this.
Larry
More information about the R-sig-Geo
mailing list