geofield_to_raster: Convert a Geofield to a Raster

View source: R/geofield_methods.R

geofield_to_rasterR Documentation

Convert a Geofield to a Raster

Description

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)
}


andrew-MET/harpIO documentation built on March 7, 2024, 7:48 p.m.