我想重现小插图中的最后一个示例marmap
:太平洋地区的“marmap-DataAnalysis”。该示例显示了以 lon = 50 为中心的世界的正交投影。示例如下:
library(marmap)
library(raster)
# Get data for the whole world. Careful: ca. 21 Mo!
world <- getNOAA.bathy(-180, 180, -90, 90, res = 15, keep = TRUE)
# Switch to raster
world.ras <- marmap::as.raster(world)
# Set the projection and project
my.proj <- "+proj=ortho +lat_0=0 +lon_0=50 +x_0=0 +y_0=0"
world.ras.proj <- projectRaster(world.ras,crs = my.proj)
# Switch back to a bathy object
world.proj <- as.bathy(world.ras.proj)
# Set colors for oceans and land masses
blues <- c("lightsteelblue4", "lightsteelblue3",
"lightsteelblue2", "lightsteelblue1")
greys <- c(grey(0.6), grey(0.93), grey(0.99))
# And plot!
plot(world.proj, image = TRUE, land = TRUE, lwd = 0.05,
bpal = list(c(0, max(world.proj, na.rm = T), greys),
c(min(world.proj, na.rm = T), 0, blues)),
axes = FALSE, xlab = "", ylab = "")
plot(world.proj, n = 1, lwd = 0.4, add = TRUE)
但是,我想将中央更改为太平洋子午线,例如 lon = 155.5。我尝试通过将投影参数更改为,
my.proj <- "+proj=ortho +lat_0=20 +lon_0=155.5 +x_0=0 +y_0=0"
但是之后,
world.ras.proj <- projectRaster(world.ras,crs = my.proj)
结果是:
Error in if (nr != x@nrows | nc != x@ncols) { :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
259 projected point(s) not finite
2: In rgdal::rawTransform(projection(raster), crs, nrow(xy), xy[, 1], :
4 projected point(s) not finite
我怎么能在太平洋地区绘制“测深世界”?