GribApiDotNet / GribApi.NET

A powerful .NET library for reading and writing GRIB 1 and 2 files
Apache License 2.0
54 stars 29 forks source link

is there any way to create GRIB1 file by reading GRIB2 file? or modify GRIB2 projection #68

Closed RajeshManam closed 7 years ago

RajeshManam commented 7 years ago

Hi, is there any way to create GRIB1 file by reading GRIB2 file? i don't want to convert to GEOTIFF/NetCDF as output needs to be GRIB for my application

i am working with GRIB1 and GRIB2 files, facing issue with some of GRIB2 files having invalid angle (Upper Right ( 370.996, 63.000) (Invalid angle, 62d59'59.97"N) or incomplete projection - please see gdalinfo output. But i observe that GRIB2 files are having this issue, so converting GRIB2 to GRIB1 might solve my issue. anyone already tried this conversion? or any guidance will be appreciated.
one way, i thought of is creating new grib file using sample template provided in Gribapi.net test data files and filling contents and other missed items, but not sure what are all fields to cover. anyone if tried please this approach?

GDALINFO - output -

Size is 145, 132 Coordinate System is: GEOGCS["Coordinate System imported from GRIB file", DATUM["unknown", SPHEROID["Sphere",6371229,0]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433]] Origin = (346.829667659722247,62.999991549618315) Pixel Size = (0.166666680555556,-0.111111099236641) Corner Coordinates: Upper Left ( 346.830, 63.000) (346d49'46.80"E, 62d59'59.97"N) Lower Left ( 346.830, 48.333) (346d49'46.80"E, 48d19'59.98"N) Upper Right ( 370.996, 63.000) (Invalid angle, 62d59'59.97"N) Lower Right ( 370.996, 48.333) (Invalid angle, 48d19'59.98"N) Center ( 358.913, 55.667) (358d54'46.81"E, 55d39'59.97"N) Band 1 Block=145x1 Type=Float64, ColorInterp=Undefined

0x1mason commented 7 years ago

There can be data loss with Grib 1 => Grib 2, but you can try gribMsg["GRIBEditionNumber"] = 1 or gribMsg["editionNumber"] = 1.

Also, which version of GribApi.NET are you using? Are the values invalid when using v1.0.0-beta? If this occurs with the latest code, then it may be a bug in the underlying lib, grib_api.

RajeshManam commented 7 years ago

Hi, thank you for response. i am using version 0.7.1.0 seems edition number is read only property. tried to change edition like //gribMsg["GRIBEditionNumber"].AsInt(1); gribMsg["editionNumber"].AsInt(1); but not able as it is read only property.

0x1mason commented 7 years ago

Try the beta and lmk if the data is still wrong.

On Jul 17, 2017 11:56 AM, "RajeshManam" notifications@github.com wrote:

Hi, thank you for response. i am using version 0.7.1.0 seems edition number id read only property. tried to change edition like this , but not able as it is read only property. gribMsg["GRIBEditionNumber"].AsInt(1); gribMsg["editionNumber"].AsInt(1);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/0x1mason/GribApi.NET/issues/68#issuecomment-315784410, or mute the thread https://github.com/notifications/unsubscribe-auth/AEX_-9rq94zhp_0V_VynMgSeumvPLv17ks5sO4JRgaJpZM4OZUvo .