Skip to content
Prev 8621 / 29559 Next

sp.correlogram

On Thu, 24 Jun 2010, Robert Pazur wrote:

            
No, from your helpful link to the data, you have projected coordinates, 
not geographical. In addition, your use of as.matrix() instead of cbind() 
has bad consequences:

str(as.matrix(points$long, points$lati))
str(cbind(points$long, points$lati))

dnearneigh() will be revised to trap this.

Had you said:

coordinates(points) <- c("long", "lati")

then:

proj4string(points) <- CRS("+proj=longlat")

you would have seen the problem, because the sp classes check for the 
bounds on objects.

So after doing:

points <-read.table("http://www.scandinavia.sk/data/moran5.csv", sep=",",
  header=T)
coordinates(points) <- c("long", "lati")
dnb <- dnearneigh(points, 0, 20)

you are good to go. Next step - how to replicate the ArcGIS Moran's I - is 
easy with the correct dnb:

moran.test(points$GRID_CODE, listw=nb2listw(dnb, style="B"))

You might use correlog() in pgirmess for distance bins, but you'll have 
more control over the bin boundaries by makin new sets of neighbours for 
your chosen bin thresholds.

Hope this helps (and thank you for reverting to the list after writing to 
me directly 70 minutes earlier. List is always best).

Roger