GribSharp.Jpeg2000
1.0.15
dotnet add package GribSharp.Jpeg2000 --version 1.0.15
NuGet\Install-Package GribSharp.Jpeg2000 -Version 1.0.15
<PackageReference Include="GribSharp.Jpeg2000" Version="1.0.15" />
<PackageVersion Include="GribSharp.Jpeg2000" Version="1.0.15" />
<PackageReference Include="GribSharp.Jpeg2000" />
paket add GribSharp.Jpeg2000 --version 1.0.15
#r "nuget: GribSharp.Jpeg2000, 1.0.15"
#:package GribSharp.Jpeg2000@1.0.15
#addin nuget:?package=GribSharp.Jpeg2000&version=1.0.15
#tool nuget:?package=GribSharp.Jpeg2000&version=1.0.15
GribSharp
This project uses CSJ2K, which is distributed under the BSD 2-Clause License.
Copyright (c) 1999-2000 JJ2000 Partners; original C# port (c) 2007-2012 Jason S. Clary; C# encoding and adaptation to Portable Class Library with platform specific support (c) 2013-2016 Anders Gustafsson, Cureos AB
CSJ2K License: https://opensource.org/license/BSD-2-Clause
GribSharp is a pure C# library for reading and decoding GRIB2 (GRIdded Binary Edition 2) files used in meteorology, oceanography, and atmospheric modeling.
The library implements the core GRIB2 data representation templates and decoding algorithms in managed code, providing a lightweight and portable solution for .NET applications.
Features
Pure C# implementation. The core package has zero external dependencies; JPEG2000 support is an opt-in add-on (CSJ2K). Compatible with Unity.
Compatible with modern .NET runtimes.
Reading of GRIB2 messages, sections, and metadata.
Rich api for easy extraction.
Direct api (more complex).
Supports reading of GRIB2 files with missing values.
Full support for GRIB2 files from NOAA NOMADS.
Support for the following Data Representation Templates:
Simple Packing
- Bit unpacking.
- Value reconstruction using:
value = (R + X × 2^E) / 10^D
IEEE Floating Point
- Direct decoding of IEEE 32-bit floating-point values.
Complex Packing
- Group references.
- Variable bit widths.
- Group-based decoding.
- First- and second-order spatial differencing reconstruction.
JPEG2000 (optional
GribSharp.Jpeg2000add-on)- JPEG2000 codestream extraction.
- Decoding through CSJ2K.
- GRIB scaling and value reconstruction.
Bitmap Section support:
- Missing value handling.
- Automatic conversion of undefined points to
float.NaN.
Dump Grib2 file to text
Packages
GribSharp ships as three NuGet packages so you only pull in the JPEG2000 dependency when you need it:
| Package | Dependencies | Use it when |
|---|---|---|
| GribSharp.Core | none | You don't need JPEG2000-packed data (template 5.40). Smallest footprint, no CSJ2K. |
| GribSharp.Jpeg2000 | GribSharp.Core + CSJ2K | Add-on that enables JPEG2000 decoding. Reference it alongside Core. |
| GribSharp | GribSharp.Core + GribSharp.Jpeg2000 | Meta-package with everything. Drop-in for previous GribSharp users. |
JPEG2000 activation is automatic: when the GribSharp.Jpeg2000 assembly is
present, the core probes and registers its decoder on first use. For trimming/AOT
scenarios where reflection is unreliable, call GribSharp.Jpeg2000.Jpeg2000Support.Register()
once at startup. Without the add-on, template 5.40 throws GribNotSupportedException.
- CSJ2K — used exclusively by the add-on for decoding JPEG2000-compressed GRIB2 fields.
Goals
GribSharp aims to provide a lightweight, cross-platform, and easy-to-integrate GRIB2 decoding library for .NET applications without relying on native GRIB tooling.
Install
These packages are available on NuGet.
# Everything (drop-in, includes JPEG2000)
dotnet add package GribSharp
# Core only, no CSJ2K dependency
dotnet add package GribSharp.Core
# Core + JPEG2000 add-on
dotnet add package GribSharp.Core
dotnet add package GribSharp.Jpeg2000
Usage
Rich API:
using GribParser;
using GribParser.Model;
byte[] data = File.ReadAllBytes("gfs_forecast.grib2");
var file = Grib2Parser.ParseFile(data);
// List all available parameters
foreach (var name in file.ParameterNames)
Console.WriteLine(name);
// Search by name (case-insensitive)
var temp = file.GetField("Temperature");
Console.WriteLine($"{temp.ParameterName} [{temp.Units}]: {temp.Values.Length} points");
// Search by enum (compile-time safe)
var rh = file[Parameter.RelativeHumidity];
// Search by level
var t2m = file.GetField(Parameter.Temperature, LevelType.HeightAboveGround, 2);
var t850 = file.GetField(Parameter.Temperature, LevelType.Isobaric, 85000);
// TryGet for optional parameters
if (file.TryGetField(Parameter.WindGust, out var gust))
Console.WriteLine($"Racha máxima: {gust.Values.Max()} {gust.Units}");
// All fields of a parameter (ej: multiple level temperature)
var allTemps = file.GetFields(Parameter.Temperature);
foreach (var f in allTemps)
Console.WriteLine($" {f.LevelDescription} = {f.LevelValue}");
// Value at coordinates
float value = t2m.GetValueAt(lat: 40.41, lon: -3.70); // Madrid
Direct API:
using GribParser;
using GribParser.Model;
byte[] data = File.ReadAllBytes("gfs_forecast.grib2");
var messages = Grib2Parser.Parse(data);
byte[] data = File.ReadAllBytes("gfs_forecast.grib2");
var messages = Grib2Parser.Parse(data);
// Iterate messages and fields
foreach (var msg in messages)
{
foreach (var f in msg.Fields)
{
Console.WriteLine($"{f.ParameterName} [{f.Units}] @ {f.LevelDescription} {f.LevelValue}");
Console.WriteLine($" Grid: {f.Grid.Ni}x{f.Grid.Nj}, Forecast +{f.ForecastTime}h");
}
// Search field inside a message
if (msg.TryGetField("Temperature", out var temp))
Console.WriteLine($" Temp min={temp.Values.Min():F1} max={temp.Values.Max():F1}");
}
// Debug: dump wgrib2 style
Console.WriteLine(Grib2Dumper.Dump(data));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CSJ2K (>= 3.0.0)
- GribSharp.Core (>= 1.0.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GribSharp.Jpeg2000:
| Package | Downloads |
|---|---|
|
GribSharp
Meta-package that pulls in GribSharp.Core and the GribSharp.Jpeg2000 add-on, providing full GRIB2 decoding including JPEG2000. Drop-in for previous GribSharp users. Use GribSharp.Core alone to avoid the CSJ2K dependency. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.15 | 169 | 6/19/2026 |
### Changed
- **Split into three NuGet packages**: `GribSharp.Core` (no external dependencies), `GribSharp.Jpeg2000` (optional CSJ2K-backed JPEG2000 add-on), and `GribSharp` (meta-package pulling in both, drop-in for previous users).
- `DataRepresentationDecoderRegistry` to register decoders for data representation templates not built into the core.
- `GribSharp.Jpeg2000.Jpeg2000Support.Register()` for explicit JPEG2000 registration (trimming/AOT).
**- The core package no longer depends on CSJ2K. JPEG2000 (template 5.40) now requires the `GribSharp.Jpeg2000` add-on; it activates automatically via reflection when present, otherwise template 5.40 throws `GribNotSupportedException`.**