dot-crop: A 'crop' wrapper

.cropR Documentation

A crop wrapper

Description

This function is a simple tryCatch wrapper for crop. The function attempts to crop a spatial layer, x, by an extent object. If this proceedure fails, the function throws a warning and returns NULL; otherwise x is cropped and returned.

Usage

.crop(x, ext, layer = c("raster", "polygon", "line", "paths", "points"))

Arguments

x

A Raster or Spatial* object.

ext

An extent object, used to crop x.

layer

A character that defines the spatial layer type. This is used to produce an informative warning message if necessary.

Details

This function is designed to support pretty_map and associated funtions.

Value

The function returns x cropped by ext or NULL with a warning if the cropping routine throws an error.

Author(s)

Edward Lavender

Examples

## Not run: 
 # Success
.crop(dat_gebco, raster::extent(dat_gebco), layer = "raster")
 # Failure
 .crop(sp::SpatialPoints(cbind(1:10, 1:10)), raster::extent(dat_gebco), layer = "raster")

## End(Not run)

edwardlavender/prettyGraphics documentation built on Jan. 19, 2025, 2:47 p.m.