, 당신은 R.
에
rgeos
패키지 및 관련 공간 도구를 사용할 수 있습니다 : 아래 는 Q의 실행 예이다
교차 선을 버퍼링 한 다음이 사이트에서 "차이"다각형을 생성하는 트릭을 수행했습니다.
예제 래스터 및 위에있는 다각형을 생성하십시오. 지금
vdata <- list(x = 1:nrow(volcano), y = 1:ncol(volcano), z = volcano)
## raw polygon data created using image(vdata); xy <- locator()
xy <- structure(list(x = c(43.4965355534823, 41.7658494766076, 36.2591210501883,
25.560334393145, 13.7602020508178, 18.7949251835441, 29.179041644792,
40.6645037913237, 44.2832110429707, 47.272577903027, 47.5872480988224
), y = c(30.0641086410103, 34.1278207016757, 37.6989616034726,
40.900674136118, 32.7732500147872, 27.4781100569505, 22.5523984682652,
22.7986840476995, 24.5226831037393, 29.3252519027075, 33.8815351222414
)), .Names = c("x", "y"))
## close the polygon
coords <- cbind(xy$x, xy$y)
coords <- rbind(coords, coords[1,])
library(sp)
## create a Spatial polygons object
poly <- SpatialPolygons(list(Polygons(list(Polygon(coords, hole = FALSE)), "1")))
## create a contour line that cuts the polygon at height 171
cl <- contourLines(vdata, levels = 171)
## for ContourLines2SLDF
library(maptools)
clines <- ContourLines2SLDF(cl)
는 라인과 교차 다각형, 다시 다각형 갖는 멀티 폴을주는 약간의 차이 라인 버퍼.
library(rgeos)
lpi <- gIntersection(poly, clines)
blpi <- gBuffer(lpi, width = 0.000001)
dpi <- gDifference(poly, blpi)
원본 데이터를 플롯하고 공간 객체에서 수동으로 추출한 다각형 반을 만듭니다.
par(mfrow = c(2,1))
image(vdata)
plot(poly, add = TRUE)
plot(SpatialPolygons(list(Polygons(list([email protected][[1]]@Polygons[[1]]), "1"))),
add = TRUE, col = "lightblue")
image(vdata)
plot(poly, add = TRUE)
cl <- contourLines(vdata, levels = 171)
plot(SpatialPolygons(list(Polygons(list([email protected][[1]]@Polygons[[2]]), "2"))),
add = TRUE, col = "lightgreen")
이 간단한 경우에는 효과가 있습니다. 시나리오에 유용 할 수 있습니다.
http://cran.r-project.org/web/views/Spatial.html을보세요 –
고마워요 ~ 로마 ~ 그걸 들여다 보겠습니다 – Marco
장난감 예를 들어 주시겠습니까? 사용중인 개체/패키지를 알려주는 것도 좋습니다. 여러 가지 가능성이 있습니다. –