当前位置:网站首页>Irregular clipping of NC data with CDO
Irregular clipping of NC data with CDO
2022-07-29 00:56:00 【GIS and climate】
CDO Processing climate data , In especial NetCDF The data format is very convenient , It can be said to be the Swiss Army knife for climate data processing .
This article takes CMIP Take the data , Give an example to illustrate how to use CDO Yes NetCDF Data clipping .
Rule tailoring
Rule tailoring is generally two methods :
Cut according to longitude and latitude
Cutting according to longitude and latitude requires a certain longitude and latitude box, That is to say lonmin,lonmax,latmin,latmax, This selection operation is in CDO What we use sellonlatbox command , For example, we should select the scope of China from the global data , Then you can use the following command :
cdo sellonlatbox,73,136,3,54 global.nc china.nc
global.nc It's the input file china.nc It's the output file
The above four numbers correspond to your target area Minimum longitude 、 Maximum longitude 、 Minimum latitude 、 Maximum latitude .
According to the grid ID To cut
This kind is generally used for special grids , Like Gauss N16 Grid this , Example usage is as follows :
cdo selindexbox,60,11,3,11 infile outfile
( Not very familiar with , Not much , Because... Is rarely used )
Irregular clipping
The results of the above rules are generally like this :

But many times what we want is the basis shp The result of irregular clipping of the file , Like this :

First we need to know , Irregular clipping is to cut unnecessary meshes mask( Set to nodata), Not to delete those grids !
There are many ways to get the above results , For example, use R、Python、MATLAB, Other number owners have also written a lot , I won't repeat . Here is a non open programming language , Methods completed directly on the command line .
The tools you want to use are CDO and GDAL( To make GIS It's usually installed GDAL), The idea is :
Gridding shp File get grid file ; Take the above file as a mask and do conditional operations with the global data .
Gridding shp file
We can use it conveniently on the command line gdal_rasterize Command to shp Rasterize the file :
gdal_rasterize -of netCDF -burn 1 -tr 0.01 0.01 china.sha china.nc
china.shp: The vector boundary of your study area china.nc: Output nc file ( Used as a mask)
By the command above , We got china.nc:

Conduct mask
CDO Provides ifthen Command to help us complete this step , Its use for :
cdo ifthen china.nc global.nc china_masked.nc
The final result is as follows :

ifthen The command has three arguments , The first is mask file , The second is to carry out mask The file of , The third is the output ; It should be noted that ,mask file ( This example is china.nc) The resolution of needs to match global.nc Consistent resolution , That's up there gdal_rasterize Of tr The following parameters need to be consistent with global.nc The grid size of is consistent .
How to reverse mask Well ?
Put the above ifthen The order was changed to ifnotthen that will do .

Reference resources
【1】cdo Official user documentation
边栏推荐
- 16. Influence of deviation, variance, regularization and learning curve on the model
- andriod6.0低功耗模式(关闭wifi、蓝牙、gps、屏幕亮度等)
- Shell programming specifications and variables
- Minimum dominating set (MDS) and its matlab code
- What opportunities does the London gold real-time market bring?
- I don't recommend you use Select*
- Protective copy & stateless
- Asynchronous mode worker thread
- UE4 common printing information methods for debugging
- 管理区解耦架构见过吗?能帮客户搞定大难题的
猜你喜欢

数仓搭建——ADS层

Summary of preprocessing methods for time series data

Huawei releases harmonyos 3.0, taking another step towards "Internet of all things"

NFTScan 与 NFTPlay 在 NFT 数据领域达成战略合作

Android必备的面试技能(含面试题和学习资料)

Requestvideoframecallback() simple instance

JWT token related configuration (global configuration identity authentication rewrites authenticate method)

15. Model evaluation and selection

面试突击69:TCP 可靠吗?为什么?

DRF -- authentication, authority, frequency source code analysis, global exception handling, automatic generation of interface documents, RBAC introduction
随机推荐
Common sparse basis and matlab code for compressed sensing
There is a span tag. If you want to do click events on it, how can you expand the click area
I don't recommend you use Select*
Xinchi technology released the latest flagship product of G9 series, equipped with six A55 cores with 1.8GHz dominant frequency
Error reporting: Rong Lianyun sends SMS verification code message 500
The method of tracking the real-time market of London Silver
armeabi-v7a架构(sv7a)
[basic course of flight control development 8] crazy shell · open source formation uav-i2c (laser ranging)
会议OA项目之会议通知&会议反馈&反馈详情功能
Surfacecontrol and surfaceflinger communication
Tips for API interface optimization
【MySQL 8】Generated Invisible Primary Keys(GIPK)
【commons-lang3专题】005- ObjectUtils 专题
(20211130更新)关于jupyter notebook的下载安装及自己的配置、主题
Android必备的面试技能(含面试题和学习资料)
主线程与守护线程
17. Design of machine learning system
ORACLE not available如何解决
Jupyter notebook中5个有趣的魔法命令
芯驰科技发布G9系列最新旗舰产品,配备6个1.8Ghz主频的A55核心