[R-sig-Geo] create listw-objects from shapefiles
Catherine Linard
linard at geog.ucl.ac.be
Mon Dec 4 16:32:32 CET 2006
Dear R-sig-geo list,
I would like to do some spatial analyses such as
moran.test, for which I need a listw. I have
shapefile data, so I tried to apply the following steps:
- create spatial polygons with readShapePoly (maptools package)
- create neighbours list by poly2nb (spdep package)
- create spatial weights with nb2listw
I get an error message for the last step saying
that my nb-object is empty but I have results in
the neigbours list object in the previous step
Here are my results:
> lyme <- readShapePoly ("Filename",
proj4string=CRS(as.character (NA)), verbose=FALSE)
> summary(lyme)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
r1 22120.69 295156.8
r2 21153.22 244018.8
Is projected: NA
proj4string : [NA]
Data attributes: different attributes
> lyme_nb <- poly2nb(as(lyme, "SpatialPolygons"))
> summary(lyme_nb)
Neighbour list object:
Number of regions: 589
Number of nonzero links: 3314
Percentage nonzero weights: 0.9552607
Average number of links: 5.626486
2 regions with no links:
44 78
Link number distribution:
0 1 2 3 4 5 6 7 8 9 10 11 12 14 15
2 2 10 35 75 170 144 86 38 17 5 1 2 1 1
2 least connected regions:
8 363 with 1 link
1 most connected region:
73 with 15 links
> lyme_w <- nb2listw(lyme_nb,glist=NULL,style="W",zero.policy=FALSE)
Error in nb2listw(lyme_nb, glist = NULL, style = "W", zero.policy = FALSE) :
Empty neighbour sets found
Is there something wrong? Do I miss something?
Thank you very much for any help!
Catherine
Catherine Linard
University of Louvain
Department of Geography
Place Pasteur, 3
B - 1348 Louvain-la-Neuve
BELGIUM
Tel: +32/10/47.28.67
Fax: +32/10/47.28.77
e-mail: linard at geog.ucl.ac.be
More information about the R-sig-Geo
mailing list