我在相同区域Behrmann投影中有一个光栅,我想把它投射到Mollweide投影和情节.
然而,当我使用以下代码执行此操作时,绘图似乎不正确,因为地图延伸到两侧,并且有各种陆地的轮廓,我不期望它们.此外,地图延伸到绘图之外窗口.
任何人都可以帮助我得到这个很好的情节?
谢谢!
使用的数据文件可以从此链接下载.
这是我到目前为止的代码:
require(rgdal)
require(maptools)
require(raster)
data(wrld_simpl)
mollCRS <- CRS('+proj=moll')
behrmannCRS <- CRS('+proj=cea +lat_ts=30')
sst <- raster("~/Dropbox/Public/sst.tif", crs=behrmannCRS)
sst_moll <- projectRaster(sst, crs=mollCRS)
wrld <- spTransform(wrld_simpl, mollCRS)
plot(sst_moll)
plot(wrld, add=TRUE)
Run Code Online (Sandbox Code Playgroud)

好吧,既然这个页面上的例子似乎有效,我试图尽可能地模仿它.我认为问题出现是因为光栅图像的最左侧和最右侧重叠.如示例中的裁剪和Lat-Lon的中间重新投影似乎可以解决您的问题.
也许这种解决方法可以成为直接解决问题的更优雅解决方案的基础,因为重新投影栅格两次并不是有益的.
# packages
library(rgdal)
library(maptools)
library(raster)
# define projections
mollCRS <- CRS('+proj=moll')
behrmannCRS <- CRS('+proj=cea +lat_ts=30')
# read data
data(wrld_simpl)
sst <- raster("~/Downloads/sst.tif", crs=behrmannCRS)
# crop sst to extent of world to avoid overlap on the seam
world_ext = projectExtent(wrld_simpl, crs = behrmannCRS)
sst_crop = crop(x = sst, y=world_ext, snap='in')
# convert sst to longlat (similar to test file)
# somehow this gets rid of the unwanted pixels outside the ellipse
sst_longlat = projectRaster(sst_crop, crs = ('+proj=longlat'))
# then convert to mollweide
sst_moll <- projectRaster(sst_longlat, crs=mollCRS, over=T)
wrld <- spTransform(wrld_simpl, mollCRS)
# plot results
plot(sst_moll)
plot(wrld, add=TRUE)
Run Code Online (Sandbox Code Playgroud)
