如何在R中的光栅文件(landsat img)上绘制空间点(矢量)

如何在R中的光栅文件(landsat img)上绘制空间点(矢量),r,spatial,raster,projection,points,R,Spatial,Raster,Projection,Points,我想在landsat合成图上绘制空间点(sp),绘制landsat作品和绘制sp,但它不能一起工作。我很确定我没有被投影/坐标系覆盖,但我不知道我做错了什么。谷歌搜索没有帮助,所以我问你 代码如下: coords_glaciers <- data.frame(x = prec_year$latitude, y = prec_year$longitude) head(coords_glaciers) x y 1 30.69800 95.10474 2 30.

我想在landsat合成图上绘制空间点(sp),绘制landsat作品和绘制sp,但它不能一起工作。我很确定我没有被投影/坐标系覆盖,但我不知道我做错了什么。谷歌搜索没有帮助,所以我问你

代码如下:

coords_glaciers <- data.frame(x = prec_year$latitude, y = prec_year$longitude)
head(coords_glaciers)

         x        y
1 30.69800 95.10474
2 30.69628 95.09544
3 30.69173 95.04394
4 30.68793 95.08615
5 30.68799 95.20155
6 30.68472 95.21425

pts_glaciers <- SpatialPoints(coords = coords_glaciers)
pts_glaciers

class       : SpatialPoints 
features    : 865 
extent      : 29.50121, 30.82512, 94.24684, 96.19304  (xmin, xmax, ymin, ymax)
coord. ref. : NA 
proj <- projection(landsat)
proj
[1] "+proj=utm +zone=46 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"

pts_glaciers <- SpatialPoints(coords = coords_glaciers, proj4string = CRS(proj))
pts_glaciers

class       : SpatialPoints 
features    : 865 
extent      : 29.50121, 30.82512, 94.24684, 96.19304  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=46 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 

plotRGB(landsat, r=5, g=4,b=3)
plot(pts_glaciers, add =TRUE)

coords\u我认为解决方案是:

coords_glaciers <- data.frame(x = prec_year$longitude, y = prec_year$latitude)

coordinates(coords_glaciers) <- c("x","y")

proj4string(coords_glaciers) <- CRS("+proj=longlat +datum=WGS84") 

pts_glaciers <- spTransform(coords_glaciers, CRS("+proj=utm +zone=46 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"))

coords\u Glacles尝试
pts\u Glacles Hi Djack,不幸的是,您的解决方案看起来没有什么不同。。。。我以前已经加载过rgdal、sp和光栅。陆地卫星的范围是多少?>陆地卫星类别:光栅堆栈尺寸:7021806156596281,9(nrow,ncol,ncell,nlayers)分辨率:30,30(x,y)范围:599685841515249585460215(xmin,xmax,ymin,ymax)坐标。参考:+proj=utm+zone=46+ellps=WGS84+towgs84=0,0,0,0,0,0+units=m+no_defs第二个命令不起作用,所以我输入了“+proj=utm+zone=46+ellps=WGS84+towgs84=0,0,0,0,0,0+units=m+no_defs”,所以命令运行良好,但问题仍然是一样的。当我分别绘制pts_冰川和陆地卫星图像时,它们似乎具有完全不同的维度。。。加上pts_冰川也没用现在我明白了,你需要在coords_glaciersHaha中切换纬度和经度,我真蠢。。。。谢谢你提供的信息,但无论如何,这个问题解决不了。当查看空间点和陆地卫星img时,它们有不同的范围,pts_冰川有地理坐标,陆地卫星有UTM坐标。更改范围仅适用于陆地卫星img,但这完全破坏了比例和点,即使它们可以添加到陆地卫星场景中,但不适合…我的回答是UTM的pts_冰川项目,上次我检查它是否适合陆地卫星的范围,所以它应该可以工作是的,你完全正确,我只是犯了一个稍微进一步的错误,但现在它起作用了。谢谢!!!