[R-sig-Geo] polygon identifiers and nb classes
Roger Bivand
Roger.Bivand at nhh.no
Wed Apr 19 16:06:11 CEST 2006
On Wed, 19 Apr 2006, Larry Layne wrote:
> 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, useful! The function will be in the next spdep release.
Roger
>
> Thanks for the effort you put into this.
>
> Larry
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list