classifying data points in buffers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

classifying data points in buffers

Gary  Nobles
I have a point data set "points"
A central location "xy"
Buffers increasing by 0.5 around "xy"

Part 1
I want to cut the buffers so they are doughnuts, then assign the number of points which are contained in each doughnut. (gContain?)

Part 2
I want to cut the doughnuts into 8 Cartesian segments (e.g. N,E,S,W, NE, NS, SE, SW), and do the same calculation.

#ring and sector using rgeos
library(sp)
library(rgeos)
#create an example point dataset
set.seed(50)
x<-rnorm(100, mean=50, sd = 1)
y<-rnorm(100, mean=50, sd = 1)
coords = cbind(x, y)
points = SpatialPoints(coords)

#central point
xy <- readWKT("POINT(50 50)")
plot(xy, xlim=c(45,55), ylim=c(45,55))
plot(points, pch=16, add = TRUE)

#buffers
plot(gBuffer(xy, width = 0.5), add=TRUE)
plot(gBuffer(xy, width = 1.0), add=TRUE)
plot(gBuffer(xy, width = 1.5), add=TRUE)
plot(gBuffer(xy, width = 2.0), add=TRUE)
plot(gBuffer(xy, width = 2.5), add=TRUE)
plot(gBuffer(xy, width = 3.0), add=TRUE)
plot(gBuffer(xy, width = 3.5), add=TRUE)
plot(gBuffer(xy, width = 4.0), add=TRUE)
plot(gBuffer(xy, width = 4.5), add=TRUE)

I am trying to replicate this analysis in R http://www.akilisoftware.nl/RingAndSectorAnalysis.html 
Reply | Threaded
Open this post in threaded view
|

Re: classifying data points in buffers

Gary  Nobles
I have got the "points" and the "rings"
both are S4 Spatial Data Frame.

How do I attach the count of points in a segment to the segment of the ring?

I've tried using the 'over' function, but I'm not getting far