RNomad to process grib2 files in R is taking too long

230 Views Asked by At

We are trying to read a grib2 containing weather forecast with 13 variables at one pressure level for 6 lat/long for one day. The grib2 file is 62mb. To read one variable of hourly data for one day it takes about an hour, particularly ReadGrib.

We are using wgrib.exe, version v2.0.3. We are using R version 3.4 in Windows 10.

Should the read take this long or are we doing something wrong. Please advise.

The code we are using is:

file <- "./xxx.grib2"

### define the geographical coordinated to be extracted
lat_list <- c(36.8200, 43.2800, 52.7200)
lon_list <- c(85.8000, 87.3500, 95.8000)

var_list <- c("APCP", "DSWRF", "PRES")
lev_list = c("surface")

### read data
data <- ReadGrib(file, variable = var_list,  levels = lev_list)

for (i in 1: length(lat_list)) {
   cat("\n", "         ... extracting point",  i,  "/",  length(lat_list))
   data_extract <- BuildProfile(data, spatial.average = F,
                    lat = lat_list[i], lon = lon_list[i])
}
1

There are 1 best solutions below

0
On

You can try to define the domain parameter in the limits of geographical interest:

domain=c(85.8000,95.8000,52.7200,36.8200)

### read data
data <- ReadGrib(file, variable = var_list,  levels = lev_list,domain=domain)