如何将经度从 0 - 360 转换为 -180 - 180 [英] how to convert longitude from 0 - 360 to -180 - 180

查看:193
本文介绍了如何将经度从 0 - 360 转换为 -180 - 180的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CMIP5 未来气候数据中的经度为 0 - 360 度.如何使用光栅包将其转换为 -180 - 180 度?

The longitude in CMIP5 future climate data is in 0 - 360 degree. How can I convert it to -180 - 180 degree using the raster package?

我尝试了 shift(r0,-180)shift(r0,-360).这没用.任何帮助将不胜感激.r0 这里是一个光栅.

I tried with shift(r0,-180) and shift(r0,-360). It does not work. Any help will be appreciated. r0 here is a raster.

推荐答案

尝试 rotate().它的帮助页面甚至提到了它对您正在处理的数据类型的效用:

Try rotate(). Its help page even mentions its utility with the type of data you're dealing with:

从 0 开始旋转具有 x 坐标(经度)的 Raster* 对象到 360,到 -180 到 180 度之间的标准坐标.0 到 360 之间的经度常用于来自全球的数据气候模型.

Rotate a Raster* object that has x coordinates (longitude) from 0 to 360, to standard coordinates between -180 and 180 degrees. Longitude between 0 and 360 is frequently used in data from global climate models.

这是一个简单的可重现示例来展示它的作用:

Here's a simple reproducible example to show what it does:

library(raster)
r <- raster(matrix(1:100, ncol=10), 0, 360, -90, 90, crs="+proj=merc")
r2 <- rotate(r)
r2
# class       : RasterLayer 
# dimensions  : 10, 10, 100  (nrow, ncol, ncell)
# resolution  : 36, 18  (x, y)
# extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=merc 
# data source : in memory
# names       : layer 
# values      : 1, 100  (min, max)

这篇关于如何将经度从 0 - 360 转换为 -180 - 180的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆