使用多边形图层下方的轮廓线切割多边形
我想根据高程将多边形图层切割成两部分(上部和下部)。多边形可能是凸的或凹的,并且切割的位置可能彼此不同。等高线的间隔为5m,这意味着我可能需要生成一个具有更浓缩的等高线的等高线,例如1m的间隔。关于如何做到这一点的任何想法,在 ArcGIS 中还是在 R 中更好? 以下是问题的运行示例:
library(sp)
library(raster)
r<-raster(ncol=100,nrow=100)
values(r)<-rep(1:100,100)
plot(r) ### I have no idea why half of the value is negative...
p1<-cbind(c(-100,-90,-50,-100),c(60,70,30,30,60))
p2<-cbind(c(0,50,100,0),c(0,-25,10,0))
p1p<-Polygons(list(Polygon(p1,hole=T)),"p1")
p2p<-Polygons(list(Polygon(p2,hole=T)),"p2")
p<-SpatialPolygons(list(p1p,p2p),1:2)
plot(p,add=T)
segments(-90,80,-90,20) ##where the polygon could be devided
segments(50,20,50,-30) ##
提前致谢~
Marco
I would like to cut a polygon layer, according to the elevation, into two parts (upper and lower part). The polygon might convex or concave, and the position to cut might vary from each other. The contour line has an interval of 5m, which means I might need to generate a contour with much condensed contour lines, e.g, 1m interval. Any idea on how to do it, better in ArcGIS, or in R?
Below is the running example for the Q:
library(sp)
library(raster)
r<-raster(ncol=100,nrow=100)
values(r)<-rep(1:100,100)
plot(r) ### I have no idea why half of the value is negative...
p1<-cbind(c(-100,-90,-50,-100),c(60,70,30,30,60))
p2<-cbind(c(0,50,100,0),c(0,-25,10,0))
p1p<-Polygons(list(Polygon(p1,hole=T)),"p1")
p2p<-Polygons(list(Polygon(p2,hole=T)),"p2")
p<-SpatialPolygons(list(p1p,p2p),1:2)
plot(p,add=T)
segments(-90,80,-90,20) ##where the polygon could be devided
segments(50,20,50,-30) ##
Thanks in advance~
Marco
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您可以使用 R 中的 rgeos 包和相关空间工具。
我采取了缓冲相交线的技巧,然后从该站点生成“差异”多边形:
http://www.chopshopgeo.com/blog/?p=89
生成示例栅格,以及覆盖多边形。
现在,将多边形与线相交,然后稍微缓冲该线,并再次与多边形进行差异以得到多部分多边形。
绘制原始数据,以及从空间对象中手动提取的多边形半部。
这适用于这个相当简单的情况,它可能对您的场景有用。
If I understand correctly, you can use the
rgeos
package and related Spatial tools in R.I took the trick to buffer an intersected line and then generate the "difference" polygon from this site:
http://www.chopshopgeo.com/blog/?p=89
Generate example raster, and an overlying polygon.
Now, intersect the polygon with the line, then buffer the line slightly and difference that again with the polygon to give a multipart poly.
Plot the original data, and the polygon halves extracted manually from the Spatial object.
That works for this fairly simple case, it might be useful for your scenario.