NetCDF全称为network Common Data Format,中文译法为“网络通用数据格式”,是一个多自变量的单值函数。目前很多数据以nc格式存储,这里从gis角度 ,分别使用Arcgis、IDL批量处理。基础了解见http://blog.renren.com/share/242186498/4248540111
1、将NetCDF文件批量导出为tiff文件:
打开Arcmap——>toolbox——>mutidimension tools——>MakeNetCDFRasterLayer
将上面生成的图像数据导出到自己的文件夹
打开IDL,运行batch.pro(程序下载:https://pan.baidu.com/s/1o7D5mzS 提取码 vw7m)
(上述代码只需要修改输入、输出的数据名称、路径即可)
2.将tiff文件再转为bat文件
等全部数据都导出相应的tiff格式后,打开Arccatalog——>conversion tools——>Raster To Other Format (multiple)
右键选择batch批量处理,加载完成之后点击OK
3.将生成的dat文件,使用c#代码(后面)合并成一个BIP格式的多波段envi文件
在以上文件夹内新建一个文本文档,命名为1.txt,里面输入一行:dir /b *.dat >1.txt
另存为1.bat,此时1.txt内就是该文件夹下所有的dat文件名
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace CompositeImage
{
class Program
{
static void Main(string[] args)
{
string TitleLine = @"F:\down\out\et\1.txt";
//读取文件的路径
string readFilePath = @"F:\down\out\et\";
string saveFile = @"F:\down\out\et\MOD16A2_ET_1km_BSQ.img";
//读取文本中的title
StreamReader readtitleline = new StreamReader(TitleLine, Encoding.Default);
//往目标文件写入
BinaryWriter Bwritefile = new BinaryWriter(new FileStream(saveFile, FileMode.Create));
//在流中读取,存暂时读取的Title
string TempLine = readtitleline.ReadLine();
//60是dat文件个数
for (int i = 0; i < 60; i++)
{
//读文件(哪一个)
string filepath = readFilePath + TempLine;
Console.WriteLine("读取{0}", TempLine);
BinaryReader Breadfile = new BinaryReader(new FileStream(filepath, FileMode.Open));
//读行列(可在dat文件的额头文件中找到)
for (int j = 0; j < 7016; j++)
{
for (int k = 0; k < 2400; k++)
{
//Breadfile.ReadInt16()是根据dat的存储类型来确定,0.1f是文件的scale,如果没有就不乘)
Bwritefile.Write(Convert.ToSingle(Breadfile.ReadInt16() * 0.1f));
}
}
Breadfile.Close();
TempLine = readtitleline.ReadLine();
}
readtitleline.Close();
Bwritefile.Close();
Console.WriteLine("完成!");
Console.Read();
}
}
}
后面根据需要,确定是否在envi中将上述的BSQ格式文件转为BIP或进行平均值统计
另外,使用matlab批处理nc数据可参考http://blog.sciencenet.cn/blog-505625-597727.html
grads批处理可参考http://blog.csdn.net/chht/article/details/5255802