construct SpatialGridDataFrame

make_grid(
  range = c(-180, 180, -90, 90),
  cellsize = 1,
  midgrid = c(TRUE, TRUE),
  prj = NULL,
  type = "base",
  fix_lon360 = FALSE
)

get_grid.lonlat(lon, lat, fix_lon360 = FALSE)

fix_lon(x)

Arguments

range

A numeric vector, [lon_min, lon_max, lat_min, lat_max]

cellsize

Numeric vector, grid cell size [cellsize_lon, cellsize_lat].

midgrid

A vector, [midgrid_lon, midgrid_lat]. If midgrid = false, then begin point and end point locate on grid lines; If true, then begin point and end point in the middle of grid.

prj

sp::CRS-class() Projection.

type

Character, one of mat or vec.

  • base: If image(x) looks correct, x can be put into grid directly: grid@data <- data.frame(x = as.numeric(x))

  • gdal: If image(x) looks correct, x needs to flipud: grid@data <- data.frame(x = as.numeric(Ipaper::flipud(x))) In version >= 0.1.3, c("mat", "vec") was renamed as c("base", "gdal").

fix_lon360

boolean

Details

The input matrix suits for image, can be directly input to make_grid.

Examples

range <- c(73, 105, 25, 40) # Tibetan Plateau
grid <- make_grid(range, cellsize = 1 / 2, midgrid = TRUE)