warpGrid: Grid warping

View source: R/warpGrid.R

warpGridR Documentation

Grid warping

Description

Warp grid to allow plotting in a different projection.

Usage

warpGrid(
  data,
  original.CRS = "+init=epsg:4326",
  new.CRS = "+init=epsg:3995",
  int.method = "bilinear"
)

Arguments

data

A C4R grid (or multimember C4R grid) object, or climatology C4R grid.

original.CRS

character as passed to function CRS with the original projection. Default to longlat projection ("+init=epsg:4326").

new.CRS

character string, as passed to function CRS, specifying the target projection. Default to polar stereographic projection ("+init=epsg:3995").

int.method

Resampling method. Default to "bilinear". See details.

Details

This function is a wrapper of the gdal warping capabilities via gdalwarp.

int.method

By default bilinear interpolation is applied to get a complete grid in the target projection. Other options are "near", "cubic", "cubicspline" etc., passed to the argument r in gdalUtils::gdalwarp.

Value

Warped grid with the structure of a C4R grid.

Author(s)

A. Casanueva, J. Bedia, M. Iturbide

Examples

library(climate4R.datasets)
data(ncep_hgt500_2000)
grid <- warpGrid(climatology(ncep_hgt500_2000))
# Example of application: plot in polar stereographic projection
library(visualizeR)
l1 <- get(load(paste0(find.package("visualizeR"), "/countries.rda"))) # world coastline
l1 <- sp::spTransform(l1[[2]], CRSobj = attr(grid$xyCoords, "projection"))
visualizeR::spatialPlot(grid, sp.layout = list(list(l1, first = FALSE)))

SantanderMetGroup/geoprocessoR documentation built on June 29, 2023, 9:41 p.m.