标签:
1、长时间序列中国NDVI数据GIMMS(下载地址:寒区旱区科学数据中心),提供Albers投影的tif格式数据集。
2、长时间序列全球NDVI数据GIMMS 3g(下载地址:Ecocast),元数据无投影,格式为VI3g,IE浏览器下载的为.txt格式。GIS软件无法直接打开,Envi 5.1打开,参照:ENVI5.1中快速打开及处理GIMMS数据。
Envi5.1中打开二进制(Binary)数据是,需要提供头文件,考虑到该数据集的大小范围都一致,可以共用一个头文件,只需要将头文件的名称与数据文件一致,由于Python和IDL知识的欠缺,最终考虑使用C#批量生成,思想是:每读到一个数据文件,按名称生成一个头文件(.hdr),而头文件的内容是在Envi5.1中打开第一个数据是生成的。
代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string path; string path2; private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim().Length == 0 || textBox2.Text.Trim().Length == 0) { MessageBox.Show("请选择数据!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string name; int n = 0;int m=0; DirectoryInfo TheFolder = new DirectoryInfo(@path); foreach (FileInfo NextFile in TheFolder.GetFiles()) n++; progressBar1.Minimum = 0; progressBar1.Maximum = n; foreach (FileInfo NextFile in TheFolder.GetFiles()) { name=NextFile.Name.Substring(0, NextFile.Name.Length - 4); this.listBox2.Items.Add(name); if (!File.Exists(path+name + ".hdr")) { FileStream myFs = new FileStream(path + name + ".hdr", FileMode.Create); StreamWriter mySw = new StreamWriter(myFs); myFs = new FileStream(path2, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(myFs); sr.BaseStream.Seek(0, SeekOrigin.Begin); string str = sr.ReadToEnd(); sr.Close(); mySw.WriteLine(str); mySw.Close(); myFs.Close(); m++; progressBar1.Value = m; label1.Text = "已生成:" + m +"/"+n+ "个"; } } MessageBox.Show("生成成功!","恭喜恭喜",MessageBoxButtons.OK,MessageBoxIcon.Information); } private void button2_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { path = folderBrowserDialog1.SelectedPath.ToString()+"\\"; textBox1.Text = path; } else textBox1.Text = ""; } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void button5_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); if(of.ShowDialog()==DialogResult.OK) { path2 = of.FileName; textBox2.Text = path2; } else { textBox2.Text = ""; } } } }
标签:
原文地址:http://blog.csdn.net/lucky51222/article/details/42127727