如何执行raster :: rotate的反转

时间:2017-01-11 17:19:21

标签: r r-raster

raster包提供了一个名为library(zoo) library(dplyr) df1 %>% group_by(PartNumber, yearMon = as.yearmon(RequestedDate, "%m/%d/%Y %H:%M")) %>% summarise(Quantity = sum(Quantity)) 的函数

  

"旋转x坐标(经度)为0的Raster *对象   360到-180到180度之间的标准坐标。   全球气候中经常使用0到360之间的经度   模型"

但是如果我们希望执行此函数的反函数将-180到180经度转换为0到360之一,那么该函数不起作用,因为它所做的就是丢弃源自经度的任何数据小于零:

rotate

enter image description here

library(maps)
library(maptools)
library(raster)
world = map("world", fill=TRUE, col="transparent", plot=FALSE)
world = map2SpatialPolygons(world, world$names, CRS("+proj=longlat +ellps=WGS84"))
world = rasterize(world, raster(nrows=100,ncols=200, ext=extent(-180,180,-90,90)))

plot(world)

enter image description here

我们如何执行plot(rotate(world)) 的反转以转换"标准坐标"范围从-180到180到0到360坐标?

1 个答案:

答案 0 :(得分:4)

这应该可以解决问题:

w2 <- shift(rotate(shift(world, 180)), 180)
plot(w2)

enter image description here

相关问题