簡體   English   中英

將shapefile轉換為多邊形

[英]convert shapefile to polygon

我有一個shapefile,它是我將在R中映射的湖泊的輪廓。我使用以下命令在shapefile中加載:

Lake <- readOGR("File directory", "Lake")

我需要此shapefile是Polygon,而不是SpatialPolygon或SpatialPolygonDataFrame。

str(Lake)
Formal class 'SpatialPolygons' [package "sp"] with 4 slots
..@ polygons   :List of 1
.. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots
.. .. .. ..@ Polygons :List of 3
.. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. .. .. .. ..@ labpt  : num [1:2] -84.7 39.6
.. .. .. .. .. .. ..@ area   : num 0.000255
.. .. .. .. .. .. ..@ hole   : logi FALSE
.. .. .. .. .. .. ..@ ringDir: int 1
.. .. .. .. .. .. ..@ coords : num [1:1333, 1:2] -84.8 -84.8 -84.8 -84.8 
.. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. .. .. .. ..@ labpt  : num [1:2] -84.8 39.6
.. .. .. .. .. .. ..@ area   : num 7.39e-07
.. .. .. .. .. .. ..@ hole   : logi TRUE
.. .. .. .. .. .. ..@ ringDir: int -1
.. .. .. .. .. .. ..@ coords : num [1:40, 1:2] -84.8 -84.8 -84.8 -84.8 
.. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. .. .. .. ..@ labpt  : num [1:2] -84.8 39.6
.. .. .. .. .. .. ..@ area   : num 3.21e-06
.. .. .. .. .. .. ..@ hole   : logi TRUE
.. .. .. .. .. .. ..@ ringDir: int -1
.. .. .. .. .. .. ..@ coords : num [1:65, 1:2] -84.8 -84.8 -84.8 -84.8  
.. .. .. ..@ plotOrder: int [1:3] 1 3 2
.. .. .. ..@ labpt    : num [1:2] -84.7 39.6
.. .. .. ..@ ID       : chr "0"
.. .. .. ..@ area     : num 0.000255
..@ plotOrder  : int 1
..@ bbox       : num [1:2, 1:2] -84.8 39.6 -84.7 39.6
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "x" "y"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84   
+towgs84=0,0,0"

使用RGeostats包來執行地統計分析,我必須使用多邊形,而不是其他任何對象類型。 這是因為我必須選擇圍繞整個湖泊的區域來進行進一步的分析。 對象db.data存儲特定緯度/經度點的魚類密度。

db.data=db.polygon(db.data, Lake)
The input object is of type ' SpatialPolygons '. It should be of type '   
polygon '
The function is interrupted
Error: Invalid object type

如何將我的shapefile讀取為多邊形?

嘗試將@polygons對象分配給一個新對象。

像這樣:

LakePolygons<-Lake@polygons

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM