If you wish to work with the raster package, you can convert geofield objects to raster using this function.
Examples
if (
requireNamespace("Rgrib2", quietly = TRUE) &
requireNamespace("harpData", quietly = TRUE)
) {
geo <- read_grid(
system.file(
"grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp",
package = "harpData"
),
"T2m"
)
meteogrid::iview(geo, legend = TRUE)
ras <- geofield_to_raster(geo)
if (require("raster")) {
plot(ras)
}
geo1 <- raster_to_geofield(ras)
meteogrid::iview(geo1, legend = TRUE)
}
#> Reading /home/andrewts/R/x86_64-pc-linux-gnu-library/4.3/harpData/grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp
#> The legacy packages maptools, rgdal, and rgeos, underpinning this package
#> will retire shortly. Please refer to R-spatial evolution reports on
#> https://r-spatial.org/r/2023/05/15/evolution4.html for details.
#> This package is now running under evolution status 0
#> Loading required package: raster
#> Loading required package: sp
#>
#> Attaching package: ‘raster’
#> The following object is masked from ‘package:harpCore’:
#>
#> bind