4

我在等面积 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)

在此处输入图像描述

4

1 回答 1

6

好吧,由于页面上的示例似乎有效,因此我尝试尽可能地模仿它。我认为出现问题是因为光栅图像的最左侧和最右侧重叠。如示例中所示,裁剪和对 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)

在此处输入图像描述

于 2014-12-17T23:09:19.950 回答