【发布时间】:2021-03-15 15:58:35
【问题描述】:
我正在使用两个空间对象 - 一个栅格图层和一个研究区域的 shapefile。我正在尝试将我的栅格裁剪为我的 shapefile,但我无法让坐标系匹配。
这是我的空间对象的摘要:
栅格图层
> testxx
class : RasterLayer
dimensions : 450, 3245, 1460250 (nrow, ncol, ncell)
resolution : 0.1109257, 0.3826826 (x, y)
extent : -179.9964, 179.9576, -89.98608, 82.22108 (xmin, xmax, ymin, ymax)
crs : NA
source : memory
names : layer
values : 5.389717e-06, 0.0002052335 (min, max)
形状文件
class : SpatialPolygonsDataFrame
features : 1
extent : 5951759, 7591708, 649338.9, 2306575 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
variables : 8
names : PRUID, PRNAME, PRENAME, PRFNAME, PREABBR, PRFABBR, BUFF_DIST, ORIG_FID
value : 35, Ontario, Ontario, Ontario, Ont., Ont., 10000, 5
这是我试过的代码:
# Add a coordinate system to the raster
crs(testxx) <- "+proj=longlat +datum=WGS84 +no_defs"
# change shapefile coordinate system
aoi <- spTransform(on_shp, crs(testxx))
但坐标本身仍然不匹配 - shapefile 仍然以米为单位,而栅格以纬度和经度为单位。
谢谢!
【问题讨论】:
-
您的光栅文件可能没有 WSG1984 坐标。所以你添加了错误的crs。试着找出正确的(也许是它的兰伯特保形圆锥,因为它经常在加拿大使用)。绘制您的栅格以查看它是否有意义。然后使用 spTransform()。
标签: r coordinates transform geospatial raster