Reputation: 339
Let's assume we have a network and a fixed point on the network (like a landmark such as a stop sign or traffic light).
I can use runiflpp(n, a linnet object)
to generate uniformly distributed points on the network but is there a way to only generate points around this landmark but still on the network? Is there a way to specify the distance like 5 or 10 meters around this point?
Upvotes: 0
Views: 59
Reputation: 4507
The help file for runiflpp()
points to rlpp()
for non-uniform random
points, and rlpp()
allows you to use a function or image on the linear
network to specify the intensity of points. So one strategy is to specify a
function or image which is a positive constant close the point of interest
(POI) and zero elsewhere:
library(spatstat.linnet)
L <- simplenet
P <- lpp(c(.5,.5), L) # POI
plot(P, main = "Point of interest (POI)")
Dfun <- distfun(P) # Distance function to POI
plot(Dfun, main = "Distance to POI")
f <- function(x, y, seg, tp){ #' Function which is 1 "close" to POI and else 0
ifelse(Dfun(x = x, y = y, seg = seg, tp = tp) < 0.3, 1, 0)
}
closefun <- linfun(f, L) # As function on the network
plot(closefun, main = "Indicator of closeness to POI")
plot(P, add = TRUE, cex = 2, pch = 20)
X <- rlpp(n = 10, f = closefun)
plot(X, main = "Random points close to POI")
Upvotes: 1