raster_intersect_sp: Intersects raster and sp objects

View source: R/raster_intersect_sp.R

raster_intersect_spR Documentation

Intersects raster and sp objects

Description

Straightforward application of crop and mask to extract the data in the intersection of Raster* and SpatialPolygonsDataframe objects.

Usage

raster_intersect_sp(
  x,
  y,
  features,
  save = FALSE,
  dirToSave,
  baseName = "x_intersect_y",
  format = "GTiff"
)

Arguments

x

Raster* object

y

SpatialPolygonsDataFrame object

features

integer vector. Should some specifying features (polygons) of y be intersected with x? When not provided, whole y is intersected with x.

save

logical. Should the output be saved? Default, FALSE.

dirToSave

character specifying where to save output. Required when save=TRUE.

baseName

character. What should be the base name of output file? Default, x_intersect_y.

format

character specifying output file format. See writeFormats for all supported formats. Default, "GTiff".

Details

When save=TRUE, writeRaster is used with argument datatype=dataType(subset(x,1)).

Value

An object of class identical to that of argument x

Examples


raster_path = system.file("extdata", "MOD13Q1_NDVI_Mohinora.tif", package = "geoTS")
rasterSTACK <- stack(raster_path)
dir.create(path=paste0(system.file("extdata", package="geoTS"), "/output_raster_inter_sp"),
          showWarnings=FALSE)
dirToSave = paste0(system.file("extdata", package="geoTS"), "/output_raster_inter_sp")

raster_intersect_sp(x=rasterSTACK, y=shp_mohinora, save=TRUE, dirToSave=dirToSave, 
                    baseName="mohinora_NDVI_2001")



geoTS documentation built on Nov. 18, 2022, 1:08 a.m.