Use Grib.Api in C# (NuGet)

Viewed 143

I am trying to use the Grib.Api package to read the content of a .grib file. The code I'm using is picked up from the gitHub code of the library (https://github.com/GribApiDotNet/GribApi.NET):

using (GribFile file = new GribFile(@"GribFiles\download.grib"))
{
    GribMessage msg = file.First();

    Console.WriteLine("Grid Type: " + msg.GridType);

    double latInDegrees = msg["latitudeOfFirstGridPoint"].AsDouble();
    // GribApi.NET normalizes the coordinate values to degrees. This follows the best practice advised by ECMWF.

    // values are also accessible as strings
    Console.WriteLine("latitudeOfFirstGridPointInDegrees = " + msg["latitudeOfFirstGridPoint"].AsString());
}

I have installed the library using nuget, but it cannot find it ( nor the GribFile class).

Has anyone encounter this situation before ? If so, what was the solution ?

PS. I have added also the env. variable as recommended on github, by the author.

Thank you!

1 Answers

I'm nearly certain it's because you're trying to use it in a .net core or .net 5+ project; create a .net framework based one instead.. I had a similar issue with this exact lib, managed to find the two projects in my scratch folder:

enter image description here

I didn't dig any further into the .net core incompatibilities, as I only needed it for a decode of one file, so just made a NETFW472 project..

Related