ERA5数据(.nc格式)导出至TIFF格式(基于ArcEngine+C#)

ERA5数据 nc格式导出至TIFF格式(基于ArcEngine+C#)

前言

C# + AE ,ERA5数据(.nc格式)导出至TIFF格式
era5再分析气象数据,nc格式,分辨率:daily,0.25°
命名:yyyymmdd_后缀.tif

代码

private void button40_Click(object sender, EventArgs e)
                {
                    
                    string[] Findfiles;
                    Findfiles = Directory.GetFiles(@"E:\cai", "*wind.nc");
                    string name = "";
                    string outname = "";
                    int k = 0;
                    string type = "WIN";
        
                    for (int i = 0; i < Findfiles.Count(); i++)
                    {
                        string year = System.IO.Path.GetFileName(Findfiles[i]).Substring(0,4);//对应年份
        
                        IWorkspaceFactory wsf = new NetCDFWorkspaceFactory();
                        IWorkspace workspace;
                        workspace = wsf.OpenFromFile(Findfiles[i], 0);
                        INetCDFWorkspace nc = (INetCDFWorkspace)workspace;
                        IStringArray vararr = nc.GetVariables();
                        IMDRasterDatasetView mdrasview = new NetCDFRasterDatasetNameClass();
                        mdrasview.Variable = "i10fg";                      //sfr-sp;  spt-d2m;  sra-msdrswrf;  tmp-t2m;   wind-i10fg 
                        mdrasview.XDimension = "longitude";
                        mdrasview.YDimension = "latitude";
                        mdrasview.BandDimension = "time";
                        IMDWorkspace mdwksp = nc as IMDWorkspace;
                        IRasterDataset rasterdataset = mdwksp.CreateView("a", (IMDDatasetView)mdrasview) as IRasterDataset;
                        IRasterBandCollection bands = rasterdataset as IRasterBandCollection;
        
                        IRaster raster = rasterdataset.CreateDefaultRaster();
                        IRasterProps rasterProps = (IRasterProps)raster;
                        IPnt pBlockSize = new Pnt();
                        pBlockSize.SetCoords(rasterProps.Width, rasterProps.Height);
                        IPixelBlock pPi
### 如何使用MATLAB读取和处理ERA5-Land NetCDF格式数据文件 #### 准备工作 为了成功读取并处理ERA5-Land数据,需确认已安装必要的工具箱。通常情况下,MATLAB自带的`ncread`函数足以应对大多数需求。 #### 数据读取方法 利用MATLAB内置命令可以直接访问NetCDF文件内的变量而无需手动调整比例因子(`scale_factor`)或偏移量(`add_offset`)等属性[^1]: ```matlab % 定义要打开的NetCDF文件路径 filename = 'path_to_your_file.nc'; % 获取指定变量名下的全部维度大小 dimsizes = ncinfo(filename, 'VarName'); % 读入具体变量的内容至内存中 variable_data = ncread(filename, 'Variable_Name'); ``` 对于某些特定场景下可能遇到的问题,比如时间戳解析错误或是地理坐标系不匹配等情况,则需要额外编写辅助程序来解决这些问题。 #### 处理示例:计算每日降水量总和 当面对按小时记录降水情况的数据集时,可以通过如下方式汇总成日度统计数据[^4]: ```matlab % 假设'precipitation_amount'为每个小时一次观测得到的结果矩阵 hourly_precipitation = ncread('your_dataset_path', 'precipitation_amount'); % 将三维数组重塑为二维表格形式以便后续操作 [num_times, num_lats, num_lons] = size(hourly_precipitation); daily_precipitation_table = reshape(sum(reshape(hourly_precipitation, [], 24), 2), [num_lats, num_lons, ceil(num_times / 24)]); % 存储结果到新的NetCDF文件或其他格式TIFF图像文件中去 geotiffwrite('output_filename.tif', daily_precipitation_table(:,:,end), R); % 这里R代表空间参照信息对象 ``` 上述代码片段展示了如何从原始逐小时累积值转换成为每天总计的过程,并最终保存成果作为GeoTIFF影像供进一步分析之用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cshgiser

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值