如何在NetCDF中更改经度范围 [英] How to change longitude range in a NetCDF

查看:160
本文介绍了如何在NetCDF中更改经度范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的NetCDF文件具有4个维度(经度,纬度,时间,水准压力)和几个变量.

My NetCDF file has 4 dimensions (longitude, latitude, time, level pressure) and several variables.

我想将经度数据[340 342 344 ... 360 0 2 4 ... 18 20]替换为[-20 -18 -16 ... -2 0 2 4 ... 18 20 ].实际上,经度是从0°到360°计算的,但我需要将其从-180°到180°.

I want to replace the longitude data which is [340 342 344 ... 360 0 2 4 ... 18 20] by [-20 -18 -16 ... -2 0 2 4 ... 18 20]. In fact the longitude is counted from 0° to 360° but I need to have it from -180° to 180°.

我在Internet上找到了一些想法,但我不知道如何应用它们.

I have found some ideas on Internet but I don't know how to apply them.

这里是一个解释:

某些netcdf文件包含严格的正值[0,360],这些值与gdal/QGis处理经度值的方式不兼容-它们不会环绕日期线.这也会导致gdalwarp以及与其他数据集结合使用时出错( [-180,180]值),则由于180度的经度偏移而导致它们未正确对齐.

"Some netcdf files contain strictly positive values [0,360] which are not compatible with the way gdal/QGis treat longitude values - they do not wrap around the dateline. This also causes errors with gdalwarp and when combined with other datasets (with [-180,180] values), they are not aligned properly due to a 180 degree longitude shift.

简单的解决方法是测试经度变量,并在IReadBlock和SRS检测中通过减去180-将[180,360]区间中的任何值转换为[-180,180]."

Simple fix is to test for longitude variables and convert any values in the [180,360] interval to [-180,180] by subtracting 180 - in IReadBlock and also in SRS detection."

我还阅读了有关"gdal-translate"的信息,但我不知道如何使用它.

I also read about "gdal-translate" but I don't know how to use it.

我的纬度也有问题-N-> S(我想要S-> N),由于"cdo invertlat",我将其反转了.

I also had a problem with the latitude which was N -> S (I wanted it S -> N) and I reversed it thanks to "cdo invertlat"

推荐答案

这是我发现的:

ncap2 -O -s 'where(lon>180) lon=lon-360' ifile ofile

我不确定它什么都不会改变,但是看起来可行.

I am not sure yet it doesn't change anything else but it seems work.

这篇关于如何在NetCDF中更改经度范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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