当前位置:网站首页>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
边栏推荐
- ORACLE not available如何解决
- B- 树 ~
- Meeting notification & meeting feedback & feedback details function of meeting OA project
- How to solve the problem that the Oracle instance cannot be started
- SurfaceControl和SurfaceFlinger通信
- 【Web开发】Flask框架基础知识
- Andriod6.0 low power mode (turn off WiFi, Bluetooth, GPS, screen brightness, etc.)
- B站“崩溃”始末 2021.07.13 我们是这样崩的(转载)
- Summary of preprocessing methods for time series data
- How to solve Oracle not available
猜你喜欢

Some operations of Ubuntu remote server configuration database (unable to locate package MySQL server, steps of installing mysql, unable to enter password when logging in MySQL)
![Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]](/img/e3/496247afdb3ea5b9a9cdb8afb0d41b.png)
Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]

Selenium docking agent and selenium wire access developer tool network

NFT 项目的 7 种市场营销策略

selenium对接代理与seleniumwire访问开发者工具NetWork

Have you seen the management area decoupling architecture? Can help customers solve big problems

【愚公系列】2022年07月 Go教学课程 020-Go容器之数组

ZABBIX deployment and monitoring

Nftscan and nftplay have reached strategic cooperation in the field of NFT data

NPM run serve stuck at 40%
随机推荐
Data warehouse construction - ads floor
"Food alliance ordering system"
[basic course of flight control development 8] crazy shell · open source formation uav-i2c (laser ranging)
Jupyter notebook中5个有趣的魔法命令
Selenium wire obtains Baidu Index
NPM run serve stuck at 40%
day8
COPU陆首群教授应邀在开放原子全球开源峰会上做主旨演讲
【commons-lang3专题】003- RandomStringUtils 专题
Andriod6.0 low power mode (turn off WiFi, Bluetooth, GPS, screen brightness, etc.)
17. Design of machine learning system
Outlier detection and open set identification (2)
Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]
Introduction of shortest path tree (SPT) and matlab code
追踪伦敦银实时行情的方法
selenium对接代理与seleniumwire访问开发者工具NetWork
Soft test --- database (4) SQL statement
小程序毕设作品之微信校园浴室预约小程序毕业设计成品(5)任务书
【Web开发】Flask框架基础知识
DRF - web development mode, API interface, API interface testing tool, restful specification, serialization and deserialization, DRF installation and use