- 积分
- 1486
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-10-27
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2012-2-13 21:50:55
|
显示全部楼层
mofangbao 发表于 2012-2-12 21:58
解决了要说解决方法的哦,哈哈,这样下次别人看到了就不用再次提问啦
NetCDFDataInfo aDataInfo = new NetCDFDataInfo();
OpenFileDialog aDlg = new OpenFileDialog();
aDlg.Filter = "NetCDF (*.nc)|*.nc";
int num_1=0;
int num_2=0;
int numLev=0;
// int ckey = 0;
if (aDlg.ShowDialog() == DialogResult.OK)
{
//Read shape or image file
comboBox1.Items.Clear();
comboBox2.Items.Clear();
comboBox3.Items.Clear();
aFile = aDlg.FileName;
aDataInfo.ReadDataInfo(aFile);
while (num_1 < aDataInfo.varList.Count)
{
if (Equals(aDataInfo.varList[num_1].varName, "lat") || Equals(aDataInfo.varList[num_1].varName, "lon") || Equals(aDataInfo.varList[num_1].varName, "time") || Equals(aDataInfo.varList[num_1].varName, "lev") || Equals(aDataInfo.varList[num_1].varName, "ilev"))
{ }
else
{
comboBox1.Items.Add(aDataInfo.varList[num_1].varName);
}
num_1++;
}
while (num_2 < aDataInfo.times.Count)
{
comboBox2.Items.Add(aDataInfo.times[num_2++]);
}
num_1 =0;
while(num_1<aDataInfo.dimList.Count)
{
if (Equals(aDataInfo.dimList[num_1].dimName, "lev"))
{
numLev = aDataInfo.dimList[num_1].dimLen;
for (int i = 0; i < numLev; i++)
{
// comboBox3.Items.Add("第"+Convert.ToString(i+1)+"层");
comboBox3.Items.Add(aDataInfo.levels);
}
break;
}
num_1++;
}
这是我提取nc数据 时间、变量名和 高度层次的函数~~~~感谢王老师提供的Meteoinfo类库~~~~特贴出来供大家分享~~~~ |
评分
-
查看全部评分
|