小编dta*_*non的帖子

在 R 中的栅格图层上绘制 shapefile

我想用顶部形状文件中的点绘制一个栅格图层。我已经检查了之前的答案,但仍然有问题。我可以毫无问题地分别绘制点形状文件和栅格图层,但不能一起绘制。

据我所知,它们应该位于相同的投影和位置。

require(maptools) 

myproj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
shape <- readShapeSpatial("directory/mypoints.shp", proj4string = CRS(myproj))

plot(r <- raster(listVI[200]))
plot(shape)
Run Code Online (Sandbox Code Playgroud)

plot r raster shapefile

5
推荐指数
1
解决办法
4773
查看次数

在 R 中使用多边形裁剪栅格:错误范围不重叠

我想使用我在 ArcGIS 中制作的多边形 shapefile 裁剪栅格堆栈,但是出现范围不重叠的错误。

首先我创建光栅堆栈:

test1 < stack("C:/mydir/test1.tif")
Run Code Online (Sandbox Code Playgroud)

定义投影

myCRS <- test1@crs
Run Code Online (Sandbox Code Playgroud)

然后读取shapefile

myExtent <- readShapePoly("C:/mydir/loc1.shp", verbose=TRUE, proj4string=myCRS)
Run Code Online (Sandbox Code Playgroud)

庄稼

myCrop <- crop(test1, myExtent)
Error in .local(x, y, ...) : extents do not overlap
Run Code Online (Sandbox Code Playgroud)

我已经寻找了一个解决方案,但我只发现投影可能是问题所在,但是它们肯定都在同一个 CRS 中:

> test1$test1.1
class       : RasterLayer 
band        : 1  (of  4  bands)
dimensions  : 10980, 10980, 120560400  (nrow, ncol, ncell)
resolution  : 10, 10  (x, y)
extent      : 6e+05, 709800, 5690220, 5800020  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs …
Run Code Online (Sandbox Code Playgroud)

r crop raster image-processing

3
推荐指数
1
解决办法
6595
查看次数

标签 统计

r ×2

raster ×2

crop ×1

image-processing ×1

plot ×1

shapefile ×1