我正在使用建议的库GribCS它没有任何示例或示例显示关于 Lat/Lon 的迭代以及它们各自的值以可读形式存储。任何想法?
user5418394
问问题
542 次
1 回答
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
}
于 2015-10-16T07:22:03.917 回答