两个没有孔的多边形之间的对称差异

时间:2016-04-27 14:03:44

标签: r polygon

考虑两条无孔的闭合曲线

曲线1:

 x=c(0.01813766,0.021240708, 0.006101686, -0.01813648, -0.021246640,-0.006100095,0.01813766)
 y=c(-0.01795111,0.002401427, 0.027535572,  0.01795129, -0.002396452, -0.027526064,-0.01795111)

曲线2

x=c(0.006476347,  0.027730840, 0.01291382, -0.006475285, -0.027740463,-0.01291557,0.006476347)
y=c(-0.023862392, -0.008557378, 0.01629330,  0.023863672,  0.008560437, -0.01628554, -0.023862392)

以下是情节:enter image description here 想要计算非重叠区域的面积。

请注意:在我们的情况下,如果我们旋转红色ploygon(例如),非重叠区域的区域将会改变,这与考虑区域之间的区别的情况不同。两个ploygon作为对称差异。

问题:我正在寻找R中的任何包/代码,可用于计算上述两个多边形之间非重叠区域的面积,这个非重叠区域对于旋转任何一个多边形。

任何帮助。提前谢谢。

1 个答案:

答案 0 :(得分:1)

rgeoslibrary(rgeos) library(sp) # Polygon 1 poly1 <- readWKT("POLYGON ((0.01813766 -0.01795111, 0.021240708 0.002401427,0.006101686 0.027535572, -0.01813648 0.01795129, -0.021246640 -0.002396452,-0.006100095 -0.027526064,0.01813766 -0.01795111))") # Polygon 2 poly2 <- readWKT("POLYGON ((0.006476347 -0.023862392, 0.027730840 -0.008557378, 0.01291382 0.01629330, -0.006475285 0.023863672, -0.027740463 0.008560437,-0.01291557 -0.01628554,0.006476347 -0.023862392))") d <- gSymdifference(poly1, poly2) > gArea(d) [1] 0.0003226174 > plot(d, col = "red") 非常适合处理R中的空间对象。

以下是一个例子:

<input ng-model="$scope.username" id="username" name="name" type="text" placeholder="Username"/>

enter image description here