Saima Bashir | 21 Jun 2012 00:17
Picon
Favicon

Spatial Weight Matrix

I want to built Spatial Weight Matrix for West Virginia only. I have downloaded shape file from US census
wesite then imported into R. I was doing following steps:

i. read.shape("C:\\Users\\sbashir\\Desktop\\R\\fe_2007_54.shp")

ii. Creat neighbors list

Wnbq <- cell2nb(6, 6, type = "queen")

summary(Wnbq)

iii. Spatial Weights

nb2listw(neighbours = Wnbr, glist=NULL, style="W", zero.policy=NULL)

I am confused about next step. I will really appreciate if someone can help me.

Thanks

Saima

	[[alternative HTML version deleted]]
Juan Tomas Sayago | 21 Jun 2012 00:41
Picon

Re: Spatial Weight Matrix

Your problem is that you have to use the shp and use it to create the
matrix.
if you need to read the shape file, probably use.
SHPFILE= readShapePoly(filename, IDvar)
you can use also readOGR from rgdal.
then use poly2nb this way.
nb.polyWV=poly2nb(SHPFILE)
the SHPFILE are in yellow because are the same.
then you convert your nb to a listw  and use it.
WVlistw=nb2listw(nb.polyWV, style="W")
I used style W for row standardization.
Hope this helps
Juan.

On Wed, Jun 20, 2012 at 6:17 PM, Saima Bashir <saimabashir11 <at> yahoo.com>wrote:

> I want to built Spatial Weight Matrix for West Virginia only. I have
> downloaded shape file from US census wesite then imported into R. I was
> doing following steps:
>
> i. read.shape("C:\\Users\\sbashir\\Desktop\\R\\fe_2007_54.shp")
>
> ii. Creat neighbors list
>
> Wnbq <- cell2nb(6, 6, type = "queen")
>
> summary(Wnbq)
>
> iii. Spatial Weights
>
(Continue reading)


Gmane