我正在尝试使用{sp}包中的“栅格化”功能从世界测深栅格图层中提取感兴趣区域的测深值。
*编辑:我发现了“提取”功能,这似乎是我想要的。
到目前为止,这是我所做的:
> class(subarea0) #This is my area of interest (Eastern Canadian Arctic Sea)
[1] "SpatialPolygons"
attr(,"package")
[1] "sp"
> extent(subarea0)
class : Extent
xmin : -82.21997
xmax : -57.21667
ymin : 60.2
ymax : 78.16666
library(marelac)
data("Bathymetry")#World bathymetric data in library (marelac)
names(Bathymetry);class(Bathymetry);str(Bathymetry)
[1] "x" "y" "z"
[1] "list"
List of 3
$ x: num [1:359] -180 -179 -178 -177 -176 ...
$ y: num [1:180] -89.5 -88.5 -87.5 -86.5 -85.5 ...
$ z: num [1:359, 1:180] 2853 2873 2873 2873 2873 ...
raster_bath<-raster(Bathymetry)#Transformed into a raster layer
extent(raster_bath) <- extent(subarea0)#Transform the extend of my raster to the extend of my SpatialPolygons
>ras_sub0<-rasterize(subarea0,raster_bath)#rasterize my SpatialPolygons (*Edits: not the function that I need here, but I am still interested to learn what results mean)
Found 2 region(s) and 10 polygon(s)
> plot(ras_sub0)
> plot(subarea0, add=TRUE)
> ras_sub0
class : RasterLayer
dimensions : 180, 359, 64620 (nrow, ncol, ncell)
resolution : 0.06964709, 0.0998148 (x, y)
extent : -82.21997, -57.21667, 60.2, 78.16666 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84
values : in memory
min value : 1
max value : 2
layer name : layer
我不明白结果。为什么每个多边形都得到2种颜色?他们的意思是什么?
最终如何获得测深深度轮廓?这与我的分辨率或更改尺寸有关吗?
*编辑:好的,我现在完成了以下操作:
v <- extract(raster_bath, subarea0)#Extract data from my Raster Layer for the locations of my SpatialPolygons
v是一个列表,我不确定要如何/以什么形式将该信息与我的空间多边形重新绑定...
谢谢!
当您说“获取测深深度等高线”时,是否意味着还要生成等高线?
—
Simbamangu