[R-sig-Geo] How to create spatial weights with several unlocalised points in polygons?

Roger Bivand Roger.Bivand at nhh.no
Fri Dec 21 21:59:58 CET 2012


On Fri, 21 Dec 2012, Julien Salanié wrote:

> Hi,
>
> My problem is the following : I have points (houses) that are in
> polygons (counties). I don't have their exact location inside the
> polygon. I would like to estimate a spatial model to relate houses'
> prices to some counties characteristics.
>
> How do I create spatial weights ? I would like to weight in the
> following manner : For all the houses in the same county would by first
> order neighboors. All the houses in the adjacent counties would be
> second-order neighboors, etc, as in contiguity matrices for areal data.

Please see nb2blocknb() in spdep. This doesn't quite do what you need, 
because it defines all other points in the same county, and all points in 
neighbouring counties, as neighbours. You might want to define a custom nb 
object for your 1st order neighbours, and then use diffnb() with the 
output of nb2blocknb() to get the 2nd order neighbours.

Hope this helps,

Roger

>
> Otherwise, I though I could randomly assign a location within the
> polygon for each house. Is it possible in R to draw spatial locations
> from polygons. Put clearly: I have 2 houses (A & B) in county C. I want
> to draw coordinates (xA, yA) and (xB,yB) inside polygon C (that is, I
> want to make sure that(xA, yA) and (xB,yB)  belong to C). And I want to
> do that for the houses and for all the polygons in my dataset.
>
> Is there a way to do that in R ?
>
> Thank you very much for your advices. All the best, Julien Salani?
>
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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