[R-sig-Geo] polygon identifiers and nb classes
Larry Layne
ljlayne at unm.edu
Thu Apr 13 18:45:55 CEST 2006
I use the following code from maptools and spdep to create a neighbors list
of class nb from a shapefile:
NMmap <- read.shape("CountyLevelData.shp")
NMpolylist <- Map2poly(NMmap,region.id=NULL,quiet=TRUE)
NMnb <- poly2nb(NMpolylist,queen=FALSE)
print(is.symmetric.nb(NMnb))
I can then use write.nb.gal to output the neighbors list to a txt file in
GAL format:
write.nb.gal(NMnb,file="E://zweightsGAL_county.txt",oldstyle=FALSE,shpfile=NULL,ind=NULL)
I understand how to read the GAL format. What is the origin of the id's
listed in the txt file (in this case the rweightsGAL_county.txt file). They
look like they are the values from the FID field + 1 in the original shape
file.
I want to use the information from the GAL format .txt file to create a
spatial weights matrix file of the form I can use in ArcGIS on the same
shapefile the data came from in the first place. (For instance, compute
Moran's I using spatial statistics extension in ArcGIS using the binary
weights connectivity matrix.) How do I know which field from the shapefile
is being used in the construction of the neighbors list for the class nb
and then being written to the txt file using write.nb.gal?
Larry Layne
ljlayne at unm.edu
More information about the R-sig-Geo
mailing list