I have the following df:
name x y
A -47 134
B -11 311
C 49 100
D -40 138
E -33 233
F 30 134
I'm using the x & y coords to generate a Voronoi tessellation enclosed by a rectangle:
library(spatstat)
library(deldir)
rectangle <- owin(c(-100,100),c(0,400))
points <- ppp(x=df$x,y=df$y, window = rectangle)
voronoi <- dirichlet(points)
plot(voronoi)
Now say i have another df, df2:
x y value
-99 2 0.24
-5 32 0.24
51 242 0.08
26 54 0.25
I know I can count the sum of points (in df2) in each polygon of my Voronoi tessellation using spatstat & quadratcount, but what if I want to count the sum of the values in each polygon instead?
To give me something like:
name x y sum_of_value
A -47 134 0.24
B -11 311 0.32
C 49 100 0
D -40 138 0
E -33 233 0
F 30 134 0.25