create_fishnet: create a "fishnet" vector based on cells of a raster

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/create_fishnet.R

Description

function to create a raster and/or polygon fishnet of specified resolution over a raster dataset. By default, the fishnet is built so that each cell corresponds to a raster cell. If the pix_for_cell argument is set, then the polygons of the fishnet are built so to include the specified number of cells in each direction. If the cellsize option is set, a fishnet of the specified resolution is created over the extent of the raster)

Usage

1
2
3
create_fishnet(in_rast, pix_for_cell = 1, cellsize = NULL,
  to_file = FALSE, out_shape = NULL, overwrite = TRUE,
  crop_layer = NULL)

Arguments

in_rast

raster file or object of class raster* on which the fishnet needs to be derived.

pix_for_cell

numeric (optional) 1/2 element numeric array specifying how many pixels of the #' raster will be included in each polygon of the fishnet (if only one element is provided, the #' same number of pixel is aggregated in each direction). Ignored if cellsize is not null, #' Default: 1

cellsize

numeric (optional) 1/2 element array specifying the dimensions of the desired #' cells in the x and y directions (if only one element is provided, the same cellsize is #' used in each direction), Default: NULL

to_file

PARAM_DESCRIPTION, Default: NULL

out_shape

PARAM_DESCRIPTION, Default: NULL

overwrite

PARAM_DESCRIPTION, Default: TRUE

crop_layer

(optional) object of class Extent. If not null, the fishnet iscropped on #' this extent, without "moving" the nodes of the grid. This is useful to crop a grid created on #' the basis of a different raster coordinates on top of a different raster, Default: NULL

Details

DETAILS

Value

OUTPUT_DESCRIPTION

Author(s)

Lorenzo Busetto, PhD (2017) email: lbusett@gmail.com

See Also

extent,res st_as_sfc,st_make_grid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
  # create a fishnet over an input raster file and save it as a shapefile
  library(raster)
  library(sprawl)
  library(rasterVis)

  in_rast  <- build_testraster(20,20,1)

  fishnet  <- create_fishnet(in_rast)
  plot_rast(in_rast, in_poly = fishnet)

  fishnet  <- create_fishnet(in_rast, pix_for_cell = c(2,2))
  plot_rast(in_rast, in_poly = fishnet)

  fishnet  <- create_fishnet(in_rast, cellsize = c(22,50))
  plot_rast(in_rast, in_poly = fishnet)
 
## End(Not run)

IREA-CNR-MI/sprawl documentation built on May 27, 2019, 1:12 p.m.