[R] help on spatial data

Roger Bivand Roger.Bivand at nhh.no
Thu May 22 10:31:32 CEST 2003


On Wed, 21 May 2003, Ronaldo Reis Jr. wrote:

> Hi, 
>  
> I have a dataset with x and y coordinates and in each point I have an 
> identity of point, in some cases I can have more then one identity by point. 
>  
> My dataset is something like this: 
>  
> > x <- rep(c(1:4),4) 
> > y <- rep(c(1:4),c(4,4,4,4)) 
> > area1 <- sample(factor(rep(c("a","b","c","d"),4))) 
> > area2 <- 
> as.factor(c(rep(c("a","b"),c(2,2)),rep(c("a","b"),c(2,2)),rep(c("c","d"),c(2,2)),rep(c("c","d"),c(2,2)))) 
>  
> to view the spatial grid: 
>  
> > plot(y~x,pch=levels(area1)[codes(area1)]) 
> > plot(y~x,pch=levels(area2)[codes(area2)]) 
>  
> I have several areas with different distribution. 
>  
> I need to compute the distance and the diference between points. 
>  
> My hypothesis is that the diference between two points increase with the 
> distance between these points. 
>  

It looks as though your points are fixed observation sites, and so the
spatial distribution of the points themselves is not what is being
observed. The observations are the categorical factor levels at the fixed
points, is that right? What does "the difference between two points" mean
- same category or different category? How can the difference "increase"? 

> In this example, the fisrt area (area1) have a random distribution, and my 
> hypothesis is false, in second area (area2) I have an aggregated distribution 
> and my hypothesis is true. 

If the points were not so "fixed", this might be approached as a marked 
point process, or if there were more points, through comparing Khat for 
the levels of the factor (spatstat, splancs). However, it feels perhaps 
more like a join count situation, counting similar/not similar neighbour 
points (spdep).

library(spdep)
xy.nb <- cell2nb(4,4)
joincount.test(area1, nb2listw(xy.nb, style="B"))
joincount.test(area2, nb2listw(xy.nb, style="B"))

(or joincount.mc() for a permutation test)

(see: Cliff, A. D., Ord, J. K. 1981 Spatial processes, Pion, p. 20.)

>  
> I real data I can have several levels of aggregation, I need testing these 
> difference of aggregations. 
>  
> I try to use the Kfn from spatial package, but I dont succeed.  
>  
> R have any package to make this analyse? 
>  
> What I need to read for this?  
>  
> Thanks for all 
>  
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list