Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-滤波器坐标_R_Filter_Coordinates_Subset_Area - Fatal编程技术网

R-滤波器坐标

R-滤波器坐标,r,filter,coordinates,subset,area,R,Filter,Coordinates,Subset,Area,我是R新手,我有一个简单的问题(依我看),但到目前为止我还没有找到解决办法。我有一组(长)2D(x,y)坐标-只是2D空间中的点,如下所示: ID x y 1 1758.56 1179.26 2 775.67 1197.14 3 296.99 1211.13 4 774.72 1223.66 5 805.41 1235.51 6 440.67 1247.59 7 1302.02 1247.93 8 1450.4 1259.13 9 664.9

我是R新手,我有一个简单的问题(依我看),但到目前为止我还没有找到解决办法。我有一组(长)2D(x,y)坐标-只是2D空间中的点,如下所示:

ID  x   y
1   1758.56 1179.26
2    775.67 1197.14
3   296.99  1211.13
4   774.72  1223.66
5   805.41  1235.51
6   440.67  1247.59
7   1302.02 1247.93
8   1450.4  1259.13
9   664.99  1265.9
10  2781.05 1291.12
etc.....
如何过滤特定区域(任何形状!)中的点(表中的行)?如何过滤指定坐标子集内的点。如何指定需要/不需要的区域子集?如何把它放在R中?:)
Thx提前了很多时间

使用
splancs
软件包的
inpip
功能检查点是否位于任何形状内

library(splancs)

set.seed(123)
my.shape <- matrix(runif(10), 5)
my.points <- data.frame(x=runif(500), y=runif(500))
my.points$in.shape <- 1:500 %in% inpip(my.points, my.shape)

plot(my.points[1:2], col=1 + my.points$in.shape)
polygon(my.shape)

这看起来像是四个问题。你有没有代码来展示你到目前为止所做的尝试?好的,这个解决方案听起来很有希望!非常感谢。我可以在inpip中放置多个多边形吗?my.points$in.shape您可以通过循环查看形状列表来完成此操作(请参见新示例)。
set.seed(127)
multi.shapes <- lapply(1:3, function(...) matrix(runif(6), 3))
my.points$in.multi.shapes <- 1:500 %in%
    unlist(lapply(multi.shapes, function(p) inpip(my.points, p)))
plot(my.points[1:2], col=1 + my.points$in.multi.shapes)
for(p in multi.shapes) polygon(p)