Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
projectRaster:太平洋地区水深测量数据(“NOAA.nc';”)的光栅投影–;太平洋上的世界地图和海洋地图_R_R Raster_Orthographic_Noaa - Fatal编程技术网

projectRaster:太平洋地区水深测量数据(“NOAA.nc';”)的光栅投影–;太平洋上的世界地图和海洋地图

projectRaster:太平洋地区水深测量数据(“NOAA.nc';”)的光栅投影–;太平洋上的世界地图和海洋地图,r,r-raster,orthographic,noaa,R,R Raster,Orthographic,Noaa,我想重现marmapvignette的最后一个例子:太平洋地区的“marmap数据分析”。该示例显示以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

我想重现
marmap
vignette的最后一个例子:太平洋地区的“marmap数据分析”。该示例显示以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)

我怎样才能在太平洋地区绘制“水深世界”?

我已经简化了你的问题(总是很好,对我来说,数据下载不起作用)。实质上:

library(raster); library(rgdal)
prj1 <- "+proj=ortho +lat_0=0 +lon_0=0 +x_0=0 +y_0=0"
prj2 <- "+proj=ortho +lat_0=20 +lon_0=155.5 +x_0=0 +y_0=0" 
r <- raster()
r <- init(r, 'col')

# works
x1 <- projectRaster(r, crs = prj1)
# fails
x2 <- projectRaster(r, crs = prj2)
库(光栅);图书馆(rgdal)

prj1这可以在
marmap
中使用当前/以前版本的
graster
软件包解决。您必须使用
getNOAA.bathy()
函数的
antimeridian=TRUE
参数和一些技巧来允许光栅包计算投影

第一个技巧是使用
lon1=lon2=0
下载数据,因为反间谍软件下载两个不同的数据集:从反间谍软件下载到lon1,从lon2下载到反间谍软件。将lon1和lon2设置为0可下载整个世界


然后,您必须手动切换回-180和180之间的经度值(而不是由
getNOAA.bathy()
animeridian
参数生成的0到360),因此
行名(world2)谢谢。期待更新。关于这个bug还有更多的细节吗?它与投影类型(+proj=ortho)有关吗?问题在于跨越日期线的投影
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
library(raster); library(rgdal)
prj1 <- "+proj=ortho +lat_0=0 +lon_0=0 +x_0=0 +y_0=0"
prj2 <- "+proj=ortho +lat_0=20 +lon_0=155.5 +x_0=0 +y_0=0" 
r <- raster()
r <- init(r, 'col')

# works
x1 <- projectRaster(r, crs = prj1)
# fails
x2 <- projectRaster(r, crs = prj2)
library(marmap)
library(raster)
# Get data for the whole world. Careful: ca. 21 Mo!
world2 <- getNOAA.bathy(0, 0, -90, 90, res = 15, keep = TRUE, antimeridian=TRUE)
rownames(world2) <- as.numeric(rownames(world2))-180

# Switch to raster
world.ras <- marmap::as.raster(world2)

# Set the projection and project
my.proj <-   "+proj=ortho +lat_0=20 +lon_0=155-180 +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)
summary(world)
# Bathymetric data of class 'bathy', with 1440 rows and 720 columns
# Latitudinal range: -89.88 to 89.88 (89.88 S to 89.88 N)
# Longitudinal range: -179.88 to 179.88 (179.88 W to 179.88 E)
# Cell size: 15 minute(s)

# Depth statistics:
#    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#  -10635   -4286   -2455   -1892     214    6798 
# 
# First 5 columns and rows of the bathymetric matrix:
#          -89.875 -89.625 -89.375 -89.125 -88.875
# -179.875    2746    2836    2893    2959    3016
# -179.625    2746    2835    2892    2958    3015
# -179.375    2746    2835    2891    2957    3014
# -179.125    2746    2834    2890    2956    3013
# -178.875    2746    2834    2889    2955    3012