spatstat

Finding euclidean distance in R{spatstat} between points, confined by an irregular polygon window

跟風遠走 提交于 2019-11-28 12:34:15
I'm trying to find the euclidean distance between two points, confined by an irregular polygon. (ie. the distance would have to be calculated as a route through the window given) Here is an reproducible example: library(spatstat) #Simple example of a polygon and points. ex.poly <- data.frame(x=c(0,5,5,2.5,0), y=c(0,0,5,2.5,5)) points <- data.frame(x=c(0.5, 2.5, 4.5), y=c(4,1,4)) bound <- owin(poly=data.frame(x=ex.poly$x, y=ex.poly$y)) test.ppp <- ppp(x=points$x, y=points$y, window=bound) pairdist.ppp(test.ppp)#distance between every point #The distance result from this function between point 1

finding point of intersection in R

耗尽温柔 提交于 2019-11-26 22:35:32
I have 2 vectors: set.seed(1) x1 = rnorm(100,0,1) x2 = rnorm(100,1,1) I want to plot these as lines and then find the intersection points of the lines, also if there are multiple points of intersection then I want to locate each of them. I have come across a similar question,and tried to solve this problem using spatstat , but I was not able to convert my combined data frame containing both vector values to psp object . If you literally just have two random vectors of numbers, you can use a pretty simple technique to get the intersection of both. Just find all points where x1 is above x2 , and