2012-07-11 2 views
14

오버 기능 (rgeos)을 사용하여 두 개의 다각형 ("grd"와 "range") 사이에 공간 오버레이를 만들려고합니다.R 또는 ArcGIS의 다각형 모양 파일에서 "고아 구멍"을 어떻게 처리 할 수 ​​있습니까?

이 코드는 모든 파일에 대해 작동하지만 하나

range.grd.overlay <- grd[!is.na(over(grd, range)), ]@data$grdID # get gridcells that overlap with range 

을하고이 오류 메시지가 얻을 :

Error in createPolygonsComment(p) : 
    rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 9 

어디 선가 Shape 파일에서 주변의 다각형이없는 구멍이 있음을 이해를하지만, 나는 그 문제를 해결하는 방법을 알아낼 수 없다. 색인 9에서 구멍을 간단히 삭제할 수 있습니까? 어떻게? ArcGIS에서 shapefile을 수정하는 해결책이 있다면 나에게도 도움이 될 것입니다.

미리 도움 주셔서 감사합니다.

감사합니다, 카슨

+0

은 아무도이 도움이 수 없습니다 우리가 GRD 또는 구조에 대한 아무 생각이 없기 때문에, : 나는 결국 공간 오버레이를 만들려고 할 때 나는 같은 오류 메시지를 얻을 것입니다 후 Esc 키를 누를 때까지 R은 동결 범위. 많은 객체에는 @ data $ grdID 슬롯이있을 수 있습니다. 이것은 재현 가능한 예를 만들기위한 작업이 필요합니다. 그러나 대화 형 지오메트리 검사기의 경우 지오메트리 도구 (무료) QGIS 또는 토폴로지 팩토리가있는 (저렴한) 매니 폴드를 사용하십시오. – mdsumner

+0

인덱스 9에서 홀을 삭제하면 효과가있는 것 같습니다. 당신이 그것을 시도하면 어떻게됩니까? 'taRifx' 패키지의'subset'은 여러분이 더 좋은 방법이 없다면 그것을 할 것입니다 (저는 요즘의 공간적 방법이 아닙니다). –

+0

좋아, 알았어, 내 문제에 대해 매우 구체적이지 않은 것에 대해 유감 : – user1012744

답변

2
모두 grd

range 클래스 SpatialPolygonsDataFrame의이다. 그래서

> str(range) 
Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots 
    [email protected] data  :'data.frame': 3 obs. of 17 variables: 
    .. ..$ OBJECTID : int [1:3] 725 726 727 
    .. ..$ SPCRECID : int [1:3] 3313 3313 3313 
    .. ..$ DATE_  : Factor w/ 1 level "19/10/2009": 1 1 1 
    .. ..$ SCINAME : Factor w/ 1 level "Synthliboramphus antiquus": 1 1 1 
    .. ..$ SOURCE : Factor w/ 1 level "Gaston & Jones, 1998; Brazil, 2009": 1 1 1 
    .. ..$ PRESENCE : int [1:3] 1 1 1 
    .. ..$ ORIGIN : int [1:3] 1 1 1 
    .. ..$ SEASONAL : int [1:3] 2 1 3 
    .. ..$ DATA_SENS : Factor w/ 0 levels: NA NA NA 
    .. ..$ SENS_COMM : Factor w/ 0 levels: NA NA NA 
    .. ..$ COMPILER : Factor w/ 1 level "Philip Taylor (BirdLife International)": 1 1 1 
    .. ..$ TAX_COM : Factor w/ 0 levels: NA NA NA 
    .. ..$ DIST_COM : Factor w/ 0 levels: NA NA NA 
    .. ..$ REVIEWERS : Factor w/ 0 levels: NA NA NA 
    .. ..$ CITATION : Factor w/ 1 level "BirdLife International and Natureserve (2011) Bird species distribution maps of the world.": 1 1 1 
    .. ..$ SHAPE_Leng: num [1:3] 190 209 1240 
    .. ..$ SHAPE_Area: num [1:3] 39 16.6 600.8 
    .. ..- attr(*, "data_types")= chr [1:17] "N" "N" "C" "C" ... 
    [email protected] polygons :List of 3 
    .. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots 
    .. .. .. [email protected] Polygons :List of 138 
    .. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots 
    .. .. .. .. .. .. [email protected] labpt : num [1:2] 178.6 51.8 
    .. .. .. .. .. .. [email protected] area : num 4.58 
    .. .. .. .. .. .. [email protected] hole : logi FALSE 
    .. .. .. .. .. .. [email protected] ringDir: int 1 
    .. .. .. .. .. .. [email protected] coords : num [1:49, 1:2] 180 180 179 179 179 ... 
    .. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots 
    .. .. .. .. .. .. [email protected] labpt : num [1:2] -172.2 52.6 

... 그리고 :

range는이 같은 구조를 가지고있다. 그래서

> str(grd) 
Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots 
    [email protected] data  :'data.frame': 40680 obs. of 12 variables: 
    .. ..$ ID  : int [1:40680] 361 362 363 364 365 366 367 368 369 370 ... 
    .. ..$ X_COORD : num [1:40680] -180 -178 -178 -176 -176 ... 
    .. ..$ Y_COORD : num [1:40680] 79.1 79.1 79.1 79.1 79.1 ... 
    .. ..$ ID_1  : Factor w/ 13713 levels "10","10000","10001",..: NA NA NA NA NA NA NA NA NA NA ... 
    .. ..$ grdID  : int [1:40680] 1 2 3 4 5 6 7 8 9 10 ... 
    .. ..$ ROW  : int [1:40680] 1 1 1 1 1 1 1 1 1 1 ... 
    .. ..$ COL  : int [1:40680] 1 2 3 4 5 6 7 8 9 10 ... 
    .. ..$ AREA  : num [1:40680] 12364 12364 12364 12364 12364 ... 
    .. ..$ PERIMETER : num [1:40680] 445 445 445 445 445 ... 
    .. ..$ MAJORITY : int [1:40680] 0 0 0 0 0 0 0 0 0 0 ... 
    .. ..$ PROP0_0062: num [1:40680] 0 0 0 0 0 0 0 0 0 0 ... 
    .. ..$ AREA_KM2 : num [1:40680] 0 0 0 0 0 0 0 0 0 0 ... 
    .. ..- attr(*, "data_types")= chr [1:12] "N" "N" "N" "C" ... 
    [email protected] polygons :List of 40680 
    .. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots 
    .. .. .. [email protected] Polygons :List of 1 
    .. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots 
    .. .. .. .. .. .. [email protected] labpt : num [1:2] -179.5 79.1 
    .. .. .. .. .. .. [email protected] area : num 5.3 
    .. .. .. .. .. .. [email protected] hole : logi FALSE 
    .. .. .. .. .. .. [email protected] ringDir: int 1 
    .. .. .. .. .. .. [email protected] coords : num [1:13, 1:2] -179 -180 -180 -180 -180 ... 
    .. .. .. [email protected] plotOrder: int 1 
    .. .. .. [email protected] labpt : num [1:2] -179.5 79.1 

... 그리고 :

grd는이 같은 구조를 가지고있다.

나는 Roger Bivand에서이 도움말을 발견하고이 3 명 중 2 문제가있는 파일 일 :

>slot(shape.input, "polygons") <- lapply(slot(shape.input, "polygons"), checkPolygonsHoles) 
>range.grd.overlay <- grd[!is.na(over(grd, range)), ]@data$grdID # get gridcells of that overlay with range polygon 

하지만 세 번째 파일에 대한 고정이 작동하지 않았다.

Error in createPolygonsComment(p) : 
    rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 13 
관련 문제