pnt.in.poly(SDMTools)
pnt.in.poly()所属R语言包:SDMTools
Point in Polygon
多边形中的点
译者:生物统计家园网 机器人LoveR
描述----------Description----------
pnt.in.poly works out if 2D points lie within the boundaries of a defined polygon. <br> <br> Note: Points that lie on the boundaries of the polygon or vertices are assumed to be within the polygon.
pnt.in.poly工作,如果2D点在于定义的多边形的边界内。 <br> <br>注意:,趴在多边形的边界或顶点的点被假定为在多边形内。
用法----------Usage----------
pnt.in.poly(pnts,poly.pnts)
参数----------Arguments----------
参数:pnts
a 2-column matrix or dataframe defining locations of the points of interest
2列的矩阵或数据框定义的兴趣点的位置
参数:poly.pnts
a 2-column matrix or dataframe defining the locations of vertices of the polygon of interest
2列的矩阵或数据框定义感兴趣的多边形的顶点的位置
Details
详细信息----------Details----------
The algorithm implements a sum of the angles made between the test point and each pair of points making up the polygon. The point is interior if the sum is 2pi, otherwise, the point is exterior if the sum is 0. This works for simple and complex polygons (with holes) given that the hole is defined with a path made up of edges into and out of the hole. <br> <br> This sum of angles is not able to consistently assign points that fall on vertices or on the boundary of the polygon. The algorithm defined here assumes that points falling on a boundary or polygon vertex are part of the polygon.
该算法实现了一个测试点和每个组成多边形的点对之间的角度的总和。该点是内部的,如果总和2pi音乐,否则,该点是外部,如果总和为0。这适用于简单和复杂的多边形(有孔),该孔定义一个路径,由流入和流出的孔边缘。参考参考这笔角度是不是能够始终如一地分配顶点或多边形的边界上的点。这里定义的算法假定落在一个边界或多边形顶点的点是该多边形的一部分。
值----------Value----------
A 3-column dataframe where the first 2 columns are the original locations of the points. The third column (names pip) is a vector of binary values where 0 represents points not with the polygon and 1 within the polygon.
A 3列的数据框,其中第2列的原始位置的点。在第三列(名称点子)是二进制值,其中0表示不与内的多边形的多边形和1点的矢量。
(作者)----------Author(s)----------
Jeremy VanDerWal <a href="mailto:jjvanderwal@gmail.com">jjvanderwal@gmail.com</a>
实例----------Examples----------
#define the points and polygon[定义点和多边形]
pnts = expand.grid(x=seq(1,6,0.1),y=seq(1,6,0.1))
polypnts = cbind(x=c(2,3,3.5,3.5,3,4,5,4,5,5,4,3,3,3,2,2,1,1,1,1,2),
y=c(1,2,2.5,2,2,1,2,3,4,5,4,5,4,3,3,4,5,4,3,2,2))
#plot the polygon and all points to be checked[绘制多边形和所有点进行检查]
plot(rbind(polypnts, pnts))
polygon(polypnts,col='#99999990')[99999990)]
#create check which points fall within the polygon[创建检查点落在多边形内的]
out = pnt.in.poly(pnts,polypnts)
head(out)
#identify points not in the polygon with an X[识别不带有X的多边形的点]
points(out[which(out$pip==0),1:2],pch='X')
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|