rstFun: Function to create rasters from xyz dataframe

Description Usage Arguments Value Author(s) See Also Examples

View source: R/FUNCTION_rstFun.R

Description

This function allows the conversion of a xyz data.frame with non-equally spaced data into a raster

Usage

1
2
3
4
5
rstFun(dta, res = 1, ext = matrix(c(-180, 90,
                                     180, 90,
                                     180, -90,
                                     -180, -90),
                                   ncol = 2, byrow = TRUE), ...)

Arguments

dta

xyz data.frame, with WGS 84 geographical coordinates. x in decimal degrees +- 180º (West, East) y in decimal degrees +- 90º (South, North)

res

Numeric. Resolution of output raster. Defaults to 1 x 1º

ext

Vector or 2x2 matrix of output raster extent. Defaults to c(-180, -90, 180, 90)

...

function to aggregate spatial data

Value

Returns a raster, with WGS 84 geographical projection

Author(s)

Marisa Vedor, Ivo da Costa, Nuno Queiroz

See Also

raster rasterize SpatialPointsDataFrame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Raster resolution
resolution <- 1

# Polygon of extent
ext = matrix(c(-180, 90,
               180, 90,
               180, -90,
               -180, -90),
             ncol = 2, byrow = TRUE)


# Read data #
tbl <- data('grid_data')

# Create raster of fishing days
rst <- rstFun(tbl[, c('x', 'y', 'nBoats')], mean, na.rm = TRUE,
              res = resolution, ext = ext)

  plot(rst)

GlobalSharkMovement/GSMP_rpackage documentation built on Feb. 13, 2021, 8:01 a.m.