Determine which points are located outside the irregular data shape in R?

I have a number of points in an area whose shape of the “trace” is highly irregular:

LE82

I would like to determine all the coordinates at the tops of the footprint. The ultimate goal is to determine which data points lie outside this fingerprint.

Does anyone have an effective way to do this?


My best idea to get closer to this is to draw a polygon based on the vertices of the green area, and then use the specified polygon coordinates to define the "outlier" points (although I'm not sure how to do this - one step in time!) .

However, when I try to create a convex hull , it obviously creates problems due to the irregular shape of my green space. [Does anyone know a way to create CONCAVE containers ?]

Alternatively, is there a way to draw polygons manually using a click on graph method?


... Again, if you have a better solution to my problem than using polygons, please certainly offer this solution!

+4
source share
1 answer

Alternatively, is there a way to draw polygons manually using the “click” graph type method?

Here is one idea. Firstly, some random points:

library(manipulate)
library(sp)
set.seed(1)
par(pch = 19, cex=.5)
x <- runif(1000)
y <- runif(1000)

, :

coords <- data.frame()
manipulate({
  plot(y~x)
  res <- manipulatorMouseClick()
  coords <<- rbind(coords, data.frame(x=res$userX, y=res$userY))
  if (length(coords)) lines(coords)
})

enter image description here

, / (. ?point.in.polygon):

res <- point.in.polygon(x, y, coords$x, coords$y)!=0 

plot(y~x, col = res + 1L)
lines(coords)

enter image description here

+2

Source: https://habr.com/ru/post/1655117/


All Articles