Re: [R] Converting .grib to excel file
Dear Richard, I could not extract the data at all. But what I found is that, the data stored in the grib file converted into raster layer, and as I had 6 met parameters for a complete year (6 × 365 × 24) the raster layer has 52,560 layer. The first layer belongs to the first parameter for the first hour and second layer to the second parameters for the first hour. . And again the seven layer belongs to the first parameter for the second hour and the layer number 8 belongs to the second param. for the second hour and this cycle is repeated until the layer number 52,560. I think writing a function to extract these data can be helpful. For example writing a function to extract the data number 1 and 7 and 13 and ... store in the first column and data number 2,8,14, stor in the second column and doing this for other parameters to complete the table and eventually create a column for Date. Can you help me to write a function. Sincerely On Wed, 26 Jun 2024, 12:44 Richard O'Keefe, wrote: > Whoops, sorry, you *did* answer "what went wrong". > > param_names <- c("param1", "param2", "param3", "param4", "param5", > "param6") > > extracted_data <- extract(raster_data, param_names, df = TRUE) > #Error in (function (classes, fdef, mtable) : > #unable to find an inherited method for function ‘extract’ for > signature ‘"SpatRaster", "character"’ > > OK. The problem is that the extract() function didn't know what to do. > What does the documentation for 'extract' say? > The error message seems to say that it is not defined for first argument > being > a SpatRaster and second argument being of type character. > > (By the way, I'm having trouble updating the terra package in Ubuntu 22.04. > That's why I'm not trying any of this out.) > > Here's what ?extract starts with: > > Extract values from a SpatRaster for a set of locations. The > locations can be a SpatVector (points, lines, polygons), a > data.frame or matrix with (x, y) or (longitude, latitude - in that > order!) coordinates, or a vector with cell numbers. > > It does NOT say that the set of locations can be a vector of strings. > > > On Wed, 26 Jun 2024 at 20:05, Richard O'Keefe wrote: > > > > I'm now inclined to go with 'search for "convert GRIB to CSV". > > https://confluence.ecmwf.int/display/CKB/How+to+convert+GRIB+to+CSV > > is the first line. I know that's not an R solution, but using software > > specifically developed for encoding, decoding, extracting, GRIB file > by the > > European Centre for Medium-Range Weather Forecasts and actively > > maintained, with an example page showing how to do it, sounds like a > > good approach. > > > > One of the major things about R is that from the very beginnings of S > > it was intended to be used with other tools. We have R communicating > > with Python and Tcl and dear knows what. Getting a specialised tool > > to do its thing is very much part of the R "way". > > Or there's gribr https://rdrr.io/github/nawendt/gribr/man/gribr.html > > which wraps ecCodes in R. > > > > I still don't understand what "doesn't work" means. Which step goes > > wrong and how does it misbehave? > > > > > > On Wed, 26 Jun 2024 at 06:02, javad bayat wrote: > > > > > > Richard, > > > Many thanks for your email. > > > I had attached the grib file to the original email to R help team but > it seems you did not receive it. > > > Unfortunately, I do not know how to reduce the volume or extract some > of the grib file data to send it for you. The file has the volume of 6 > Megabyte. > > > I can send it by email. > > > The file has 6 met parameters and Date (day/month/year hour:minute). > > > I want the exported file as excel contains 7 columns (Date + 6 met > parameters). > > > > > > > > > On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: > > >> > > >> Your message referred to an attached file but there was no attachment, > > >> I have no account at that service, so could not download a sample for > > >> myself. Does the licence for the data even allow you to send some of > > >> it in a message? Which parameters are you extracting? When you say > > >> "it didn't work", what actually happened? Which step went wrong and > how? > > >> > > >> > > >> On Tue, 25 Jun 2024 at 20:33, javad bayat > wrote: > > >> > > > >> > Dear all; > > >> > I have downloaded meteorology data from " > > >> > > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form > " > > >> > as .grib format. It has hourly data of a complete year (every hour > of every > > >> > day of 12 months) and has 6 meteorology parameters. The file has > been > > >> > attached. > > >> > I am trying to convert it to an excel file that puts every > parameter in a > > >> > separated column. For instance, the first col represents Date, 2nd > > >> > represents Temperature and so on. > > >> > Is there any way to do it? > > >> > I used these codes but did not work: > > >> > # install.packages("rNOMADS") > > >> > > > >> >
Re: [R] Converting .grib to excel file
Whoops, sorry, you *did* answer "what went wrong". > param_names <- c("param1", "param2", "param3", "param4", "param5", "param6") > extracted_data <- extract(raster_data, param_names, df = TRUE) #Error in (function (classes, fdef, mtable) : #unable to find an inherited method for function ‘extract’ for signature ‘"SpatRaster", "character"’ OK. The problem is that the extract() function didn't know what to do. What does the documentation for 'extract' say? The error message seems to say that it is not defined for first argument being a SpatRaster and second argument being of type character. (By the way, I'm having trouble updating the terra package in Ubuntu 22.04. That's why I'm not trying any of this out.) Here's what ?extract starts with: Extract values from a SpatRaster for a set of locations. The locations can be a SpatVector (points, lines, polygons), a data.frame or matrix with (x, y) or (longitude, latitude - in that order!) coordinates, or a vector with cell numbers. It does NOT say that the set of locations can be a vector of strings. On Wed, 26 Jun 2024 at 20:05, Richard O'Keefe wrote: > > I'm now inclined to go with 'search for "convert GRIB to CSV". > https://confluence.ecmwf.int/display/CKB/How+to+convert+GRIB+to+CSV > is the first line. I know that's not an R solution, but using software > specifically developed for encoding, decoding, extracting, GRIB file by the > European Centre for Medium-Range Weather Forecasts and actively > maintained, with an example page showing how to do it, sounds like a > good approach. > > One of the major things about R is that from the very beginnings of S > it was intended to be used with other tools. We have R communicating > with Python and Tcl and dear knows what. Getting a specialised tool > to do its thing is very much part of the R "way". > Or there's gribr https://rdrr.io/github/nawendt/gribr/man/gribr.html > which wraps ecCodes in R. > > I still don't understand what "doesn't work" means. Which step goes > wrong and how does it misbehave? > > > On Wed, 26 Jun 2024 at 06:02, javad bayat wrote: > > > > Richard, > > Many thanks for your email. > > I had attached the grib file to the original email to R help team but it > > seems you did not receive it. > > Unfortunately, I do not know how to reduce the volume or extract some of > > the grib file data to send it for you. The file has the volume of 6 > > Megabyte. > > I can send it by email. > > The file has 6 met parameters and Date (day/month/year hour:minute). > > I want the exported file as excel contains 7 columns (Date + 6 met > > parameters). > > > > > > On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: > >> > >> Your message referred to an attached file but there was no attachment, > >> I have no account at that service, so could not download a sample for > >> myself. Does the licence for the data even allow you to send some of > >> it in a message? Which parameters are you extracting? When you say > >> "it didn't work", what actually happened? Which step went wrong and how? > >> > >> > >> On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: > >> > > >> > Dear all; > >> > I have downloaded meteorology data from " > >> > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form; > >> > as .grib format. It has hourly data of a complete year (every hour of > >> > every > >> > day of 12 months) and has 6 meteorology parameters. The file has been > >> > attached. > >> > I am trying to convert it to an excel file that puts every parameter in a > >> > separated column. For instance, the first col represents Date, 2nd > >> > represents Temperature and so on. > >> > Is there any way to do it? > >> > I used these codes but did not work: > >> > # install.packages("rNOMADS") > >> > > >> > library(rNOMADS) > >> > > >> > # Read GRIB data > >> > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") > >> > > >> > # Convert to a data frame > >> > grib_df <- as.data.frame(grib_data) > >> > > >> > # Write the data frame to a CSV file > >> > write.csv(grib_df, file = "output.csv") > >> > > >> > > >> > I would be more than happy if anyone could help me. > >> > Sincerely > >> > > >> > -- > >> > Best Regards > >> > Javad Bayat > >> > M.Sc. Environment Engineering > >> > Alternative Mail: bayat...@yahoo.com > >> > __ > >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> > https://stat.ethz.ch/mailman/listinfo/r-help > >> > PLEASE do read the posting guide > >> > http://www.R-project.org/posting-guide.html > >> > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
I'm now inclined to go with 'search for "convert GRIB to CSV". https://confluence.ecmwf.int/display/CKB/How+to+convert+GRIB+to+CSV is the first line. I know that's not an R solution, but using software specifically developed for encoding, decoding, extracting, GRIB file by the European Centre for Medium-Range Weather Forecasts and actively maintained, with an example page showing how to do it, sounds like a good approach. One of the major things about R is that from the very beginnings of S it was intended to be used with other tools. We have R communicating with Python and Tcl and dear knows what. Getting a specialised tool to do its thing is very much part of the R "way". Or there's gribr https://rdrr.io/github/nawendt/gribr/man/gribr.html which wraps ecCodes in R. I still don't understand what "doesn't work" means. Which step goes wrong and how does it misbehave? On Wed, 26 Jun 2024 at 06:02, javad bayat wrote: > > Richard, > Many thanks for your email. > I had attached the grib file to the original email to R help team but it > seems you did not receive it. > Unfortunately, I do not know how to reduce the volume or extract some of the > grib file data to send it for you. The file has the volume of 6 Megabyte. > I can send it by email. > The file has 6 met parameters and Date (day/month/year hour:minute). > I want the exported file as excel contains 7 columns (Date + 6 met > parameters). > > > On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: >> >> Your message referred to an attached file but there was no attachment, >> I have no account at that service, so could not download a sample for >> myself. Does the licence for the data even allow you to send some of >> it in a message? Which parameters are you extracting? When you say >> "it didn't work", what actually happened? Which step went wrong and how? >> >> >> On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: >> > >> > Dear all; >> > I have downloaded meteorology data from " >> > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form; >> > as .grib format. It has hourly data of a complete year (every hour of every >> > day of 12 months) and has 6 meteorology parameters. The file has been >> > attached. >> > I am trying to convert it to an excel file that puts every parameter in a >> > separated column. For instance, the first col represents Date, 2nd >> > represents Temperature and so on. >> > Is there any way to do it? >> > I used these codes but did not work: >> > # install.packages("rNOMADS") >> > >> > library(rNOMADS) >> > >> > # Read GRIB data >> > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") >> > >> > # Convert to a data frame >> > grib_df <- as.data.frame(grib_data) >> > >> > # Write the data frame to a CSV file >> > write.csv(grib_df, file = "output.csv") >> > >> > >> > I would be more than happy if anyone could help me. >> > Sincerely >> > >> > -- >> > Best Regards >> > Javad Bayat >> > M.Sc. Environment Engineering >> > Alternative Mail: bayat...@yahoo.com >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
Dear all; I used the terra package to export .grib data as an excel file but I could not do it. The grib file is readed and converted to raster correctly. It contains hourly data of a complete year for 6 met parameters (365 * 24 * 6 = 52,560). In the "raster_data" it can be seen as "nlyr" ( dimensions : 1, 1, 52560 (nrow, ncol, nlyr) ). It also contains the Date values which start from 01/01/2019 00:00 to 31/12/2019 23:00. What I am trying to do is: Export the data as an Excel file, ensuring that the met parameters are placed in separate columns and sorted from the first hour on the first day to the end of the date (31/12/2019 23:00). Here are the codes: > library(terra) > grib_file <- "C:/Users/admin/Downloads/Met.grib" > raster_data <- rast(grib_file) > raster_data class : SpatRaster dimensions : 1, 1, 52560 (nrow, ncol, nlyr) resolution : 0.25, 0.25 (x, y) extent : 49.725, 49.975, 33.965, 34.215 (xmin, xmax, ymin, ymax) coord. ref. : lon/lat Coordinate System imported from GRIB file source : Met.grib names : SFC (~[m/s], SFC (~[m/s], SFC (~e [C], SFC (~ [Pa], SFC (~) [-], SFC (~n [m], ... unit: m/s, m/s, C, Pa, -, m, ... time: 2019-01-01 to 2019-12-31 23:00:00 UTC > raster_data[[1]] class : SpatRaster dimensions : 1, 1, 1 (nrow, ncol, nlyr) resolution : 0.25, 0.25 (x, y) extent : 49.725, 49.975, 33.965, 34.215 (xmin, xmax, ymin, ymax) coord. ref. : lon/lat Coordinate System imported from GRIB file source : Met.grib name: SFC (Ground or water surface); 10 metre u wind component [m/s] unit: m/s time: 2019-01-01 UTC > raster_data[[52560]] class : SpatRaster dimensions : 1, 1, 1 (nrow, ncol, nlyr) resolution : 0.25, 0.25 (x, y) extent : 49.725, 49.975, 33.965, 34.215 (xmin, xmax, ymin, ymax) coord. ref. : lon/lat Coordinate System imported from GRIB file source : Met.grib name: SFC (Ground or water surface); Total precipitation [m] unit: m time: 2019-12-31 23:00:00 UTC # Extracting data for each parameter > param_names <- c("param1", "param2", "param3", "param4", "param5", "param6") > extracted_data <- extract(raster_data, param_names, df = TRUE) #Error in (function (classes, fdef, mtable) : #unable to find an inherited method for function ‘extract’ for signature ‘"SpatRaster", "character"’ > param_values <- lapply(raster_data, param_names) #Error: std::bad_alloc How can I do this? I have no idea how to extract some of the .grib file to attach it. Sincerely On Tue, Jun 25, 2024 at 8:38 PM javad bayat wrote: > Dear Bert and Sara; > I have searched on the internet and found some way to do this like python. > But python is so complicated to me as it needs many steps to be done for > reading and converting it. > I will try terra package to convert it. > > > On Tue, 25 Jun 2024, 15:15 javad bayat, wrote: > >> Richard, >> Many thanks for your email. >> I had attached the grib file to the original email to R help team but it >> seems you did not receive it. >> Unfortunately, I do not know how to reduce the volume or extract some of >> the grib file data to send it for you. The file has the volume of 6 >> Megabyte. >> I can send it by email. >> The file has 6 met parameters and Date (day/month/year hour:minute). >> I want the exported file as excel contains 7 columns (Date + 6 met >> parameters). >> >> >> On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: >> >>> Your message referred to an attached file but there was no attachment, >>> I have no account at that service, so could not download a sample for >>> myself. Does the licence for the data even allow you to send some of >>> it in a message? Which parameters are you extracting? When you say >>> "it didn't work", what actually happened? Which step went wrong and how? >>> >>> >>> On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: >>> > >>> > Dear all; >>> > I have downloaded meteorology data from " >>> > >>> https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form >>> " >>> > as .grib format. It has hourly data of a complete year (every hour of >>> every >>> > day of 12 months) and has 6 meteorology parameters. The file has been >>> > attached. >>> > I am trying to convert it to an excel file that puts every parameter >>> in a >>> > separated column. For instance, the first col represents Date, 2nd >>> > represents Temperature and so on. >>> > Is there any way to do it? >>> > I used these codes but did not work: >>> > # install.packages("rNOMADS") >>> > >>> > library(rNOMADS) >>> > >>> > # Read GRIB data >>> > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") >>> > >>> > # Convert to a data frame >>> > grib_df <- as.data.frame(grib_data) >>> > >>> > # Write the data frame to a CSV file >>> > write.csv(grib_df, file = "output.csv") >>> > >>> > >>> > I would be more than
Re: [R] Converting .grib to excel file
Dear Bert and Sara; I have searched on the internet and found some way to do this like python. But python is so complicated to me as it needs many steps to be done for reading and converting it. I will try terra package to convert it. On Tue, 25 Jun 2024, 15:15 javad bayat, wrote: > Richard, > Many thanks for your email. > I had attached the grib file to the original email to R help team but it > seems you did not receive it. > Unfortunately, I do not know how to reduce the volume or extract some of > the grib file data to send it for you. The file has the volume of 6 > Megabyte. > I can send it by email. > The file has 6 met parameters and Date (day/month/year hour:minute). > I want the exported file as excel contains 7 columns (Date + 6 met > parameters). > > > On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: > >> Your message referred to an attached file but there was no attachment, >> I have no account at that service, so could not download a sample for >> myself. Does the licence for the data even allow you to send some of >> it in a message? Which parameters are you extracting? When you say >> "it didn't work", what actually happened? Which step went wrong and how? >> >> >> On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: >> > >> > Dear all; >> > I have downloaded meteorology data from " >> > >> https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form >> " >> > as .grib format. It has hourly data of a complete year (every hour of >> every >> > day of 12 months) and has 6 meteorology parameters. The file has been >> > attached. >> > I am trying to convert it to an excel file that puts every parameter in >> a >> > separated column. For instance, the first col represents Date, 2nd >> > represents Temperature and so on. >> > Is there any way to do it? >> > I used these codes but did not work: >> > # install.packages("rNOMADS") >> > >> > library(rNOMADS) >> > >> > # Read GRIB data >> > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") >> > >> > # Convert to a data frame >> > grib_df <- as.data.frame(grib_data) >> > >> > # Write the data frame to a CSV file >> > write.csv(grib_df, file = "output.csv") >> > >> > >> > I would be more than happy if anyone could help me. >> > Sincerely >> > >> > -- >> > Best Regards >> > Javad Bayat >> > M.Sc. Environment Engineering >> > Alternative Mail: bayat...@yahoo.com >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
Richard, Many thanks for your email. I had attached the grib file to the original email to R help team but it seems you did not receive it. Unfortunately, I do not know how to reduce the volume or extract some of the grib file data to send it for you. The file has the volume of 6 Megabyte. I can send it by email. The file has 6 met parameters and Date (day/month/year hour:minute). I want the exported file as excel contains 7 columns (Date + 6 met parameters). On Tue, 25 Jun 2024, 15:54 Richard O'Keefe, wrote: > Your message referred to an attached file but there was no attachment, > I have no account at that service, so could not download a sample for > myself. Does the licence for the data even allow you to send some of > it in a message? Which parameters are you extracting? When you say > "it didn't work", what actually happened? Which step went wrong and how? > > > On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: > > > > Dear all; > > I have downloaded meteorology data from " > > > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form > " > > as .grib format. It has hourly data of a complete year (every hour of > every > > day of 12 months) and has 6 meteorology parameters. The file has been > > attached. > > I am trying to convert it to an excel file that puts every parameter in a > > separated column. For instance, the first col represents Date, 2nd > > represents Temperature and so on. > > Is there any way to do it? > > I used these codes but did not work: > > # install.packages("rNOMADS") > > > > library(rNOMADS) > > > > # Read GRIB data > > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") > > > > # Convert to a data frame > > grib_df <- as.data.frame(grib_data) > > > > # Write the data frame to a CSV file > > write.csv(grib_df, file = "output.csv") > > > > > > I would be more than happy if anyone could help me. > > Sincerely > > > > -- > > Best Regards > > Javad Bayat > > M.Sc. Environment Engineering > > Alternative Mail: bayat...@yahoo.com > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
Hi, While Bert is correct that there are plenty of tools, my preferred approach is to use the terra package to load a grib as a raster stack. >From there, it's straightforward to use all the spatial tools with the data, or to extract it in whatever form and with whatever dimensions you wish. GIven the multidimensional nature of the data, "straightforward" may require some fiddling to get the format and variables you want in the way you want them. Sarah On Tue, Jun 25, 2024 at 4:33 AM javad bayat wrote: > Dear all; > I have downloaded meteorology data from " > > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form > " > as .grib format. It has hourly data of a complete year (every hour of every > day of 12 months) and has 6 meteorology parameters. The file has been > attached. > I am trying to convert it to an excel file that puts every parameter in a > separated column. For instance, the first col represents Date, 2nd > represents Temperature and so on. > Is there any way to do it? > I used these codes but did not work: > # install.packages("rNOMADS") > > library(rNOMADS) > > # Read GRIB data > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") > > # Convert to a data frame > grib_df <- as.data.frame(grib_data) > > # Write the data frame to a CSV file > write.csv(grib_df, file = "output.csv") > > > I would be more than happy if anyone could help me. > Sincerely > > -- > Best Regards > Javad Bayat > M.Sc. Environment Engineering > Alternative Mail: bayat...@yahoo.com > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Sarah Goslee (she/her) http://www.sarahgoslee.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
Do a web search on "convert grib data to csv". You will get many hits. You probably don't need R to do this. -- Bert On Tue, Jun 25, 2024 at 1:33 AM javad bayat wrote: > Dear all; > I have downloaded meteorology data from " > > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form > " > as .grib format. It has hourly data of a complete year (every hour of every > day of 12 months) and has 6 meteorology parameters. The file has been > attached. > I am trying to convert it to an excel file that puts every parameter in a > separated column. For instance, the first col represents Date, 2nd > represents Temperature and so on. > Is there any way to do it? > I used these codes but did not work: > # install.packages("rNOMADS") > > library(rNOMADS) > > # Read GRIB data > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") > > # Convert to a data frame > grib_df <- as.data.frame(grib_data) > > # Write the data frame to a CSV file > write.csv(grib_df, file = "output.csv") > > > I would be more than happy if anyone could help me. > Sincerely > > -- > Best Regards > Javad Bayat > M.Sc. Environment Engineering > Alternative Mail: bayat...@yahoo.com > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting .grib to excel file
Your message referred to an attached file but there was no attachment, I have no account at that service, so could not download a sample for myself. Does the licence for the data even allow you to send some of it in a message? Which parameters are you extracting? When you say "it didn't work", what actually happened? Which step went wrong and how? On Tue, 25 Jun 2024 at 20:33, javad bayat wrote: > > Dear all; > I have downloaded meteorology data from " > https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form; > as .grib format. It has hourly data of a complete year (every hour of every > day of 12 months) and has 6 meteorology parameters. The file has been > attached. > I am trying to convert it to an excel file that puts every parameter in a > separated column. For instance, the first col represents Date, 2nd > represents Temperature and so on. > Is there any way to do it? > I used these codes but did not work: > # install.packages("rNOMADS") > > library(rNOMADS) > > # Read GRIB data > grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") > > # Convert to a data frame > grib_df <- as.data.frame(grib_data) > > # Write the data frame to a CSV file > write.csv(grib_df, file = "output.csv") > > > I would be more than happy if anyone could help me. > Sincerely > > -- > Best Regards > Javad Bayat > M.Sc. Environment Engineering > Alternative Mail: bayat...@yahoo.com > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting .grib to excel file
Dear all; I have downloaded meteorology data from " https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form; as .grib format. It has hourly data of a complete year (every hour of every day of 12 months) and has 6 meteorology parameters. The file has been attached. I am trying to convert it to an excel file that puts every parameter in a separated column. For instance, the first col represents Date, 2nd represents Temperature and so on. Is there any way to do it? I used these codes but did not work: # install.packages("rNOMADS") library(rNOMADS) # Read GRIB data grib_data <- ReadGrib("C:/Users/admin/Downloads/Met.grib") # Convert to a data frame grib_df <- as.data.frame(grib_data) # Write the data frame to a CSV file write.csv(grib_df, file = "output.csv") I would be more than happy if anyone could help me. Sincerely -- Best Regards Javad Bayat M.Sc. Environment Engineering Alternative Mail: bayat...@yahoo.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.