当我绘制“星星”对象的 bbox 时,bbox 小于对象本身。我的代码可能有错误,但我不知道在哪里......
事实上,两个问题合二为一,第二个问题出乎意料,因为它发生在我准备我的 reprex 时(见下文):虽然 bbox 绘制在“绘图窗格”中,但它没有出现在来自 REPREX 的图像上。可能 add=TRUE 有问题...
如果有人可以帮助我解决这两个问题,我将不胜感激。
这是 REPREX:
library(stars)
#> Le chargement a nécessité le package : abind
#> Le chargement a nécessité le package : sf
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(sf)
tif <- system.file("tif/L7_ETMs.tif", package = "stars")
tif <- read_stars(tif)
# 1 - plotting the first band of stars object
plot(tif[,,,1], main = NULL, key.pos = NULL)
#> downsample set to c(0,0,1)
# 2 - plotting the bbox of the raster
plot(st_geometry(st_sfc(st_polygon(list(cbind(c(st_bbox(tif)[[1]],
st_bbox(tif)[[3]],
st_bbox(tif)[[3]],
st_bbox(tif)[[1]],
st_bbox(tif)[[1]]),
c(st_bbox(tif)[[2]],
st_bbox(tif)[[2]],
st_bbox(tif)[[4]],
st_bbox(tif)[[4]],
st_bbox(tif)[[2]])))),
crs = st_crs(tif))),
border = "red", lwd = 5, add = TRUE)
由reprex 包于 2021-08-03 创建 (v2.0.0 )