我正在使用建议的库GribCS它没有任何示例或示例显示有关Lat / Lon的迭代,其各自的值以可读形式存储。有什么想法吗?
答案 0 :(得分:1)
要做到这一点,你必须使用坐标迭代,如下所示,你必须设置你的需要参数条件来提取相关的值。
static void ReadGribTwoFile()
{
#region Grib 2 Code
Grib2Input input = new Grib2Input(RandomAccessFile);
if (!input.scan(false, false))
{
Console.WriteLine("Failed to successfully scan grib file");
return;
}
Grib2Data data = new Grib2Data(RandomAccessFile);
var records = input.Records;
foreach (Grib2Record record in records)
{
IGrib2IndicatorSection iis = record.Is;
IGrib2IdentificationSection id = record.ID;
IGrib2ProductDefinitionSection pdsv = record.PDS;
IGrib2GridDefinitionSection gdsv = record.GDS;
long time = id.RefTime.AddTicks(record.PDS.ForecastTime * 3600000).Ticks;
Console.WriteLine("Record description at " + " forecast " + new DateTime(time) + ": " + string.Format("{0} {1} {2}", iis.Discipline, pdsv.ParameterCategory, pdsv.ParameterNumber));
float[] values = data.getData(record.getGdsOffset(), record.getPdsOffset());
if ((iis.Discipline == 0) && (pdsv.ParameterCategory == 1) && (pdsv.ParameterNumber == 1))
{
// RH
int c = 0;
for (double lat = gdsv.La1; lat >= gdsv.La2; lat = lat - gdsv.Dy)
{
for (double lon = gdsv.Lo1; lon <= gdsv.Lo2; lon = lon + gdsv.Dx)
{
Console.WriteLine("RH " + lat + "\t" + lon + "\t" + values[c]);
c++;
}
}
}
}
#endregion
}