Skip to contents

If you wish to work with the raster package, you can convert geofield objects to raster using this function.

Usage

geofield_to_raster(x)

raster_to_geofield(x)

Arguments

x

A geofield for geofield_to_raster, or a raster for raster_to_geofield.

Value

A raster for geofield_to_raster, or a geofield for raster_to_geofield.

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