R/30_gadm_crop.R

Defines functions gadm_crop.gadm_sp gadm_crop.gadm_sf

# gadm_crop.gadm_sf -------------------------------------------------------
# =========================================================================
gadm_crop.gadm_sf <- function(x, xmin, ymin, xmax, ymax) {
  .x <- x
  .x$sf <- sf::st_crop(.x$sf, xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax)
  .x
}

# gadm_crop.gadm_sp -------------------------------------------------------------------------------------------
# =================================================================================================================
gadm_crop.gadm_sp <- function(x, xmin, ymin, xmax, ymax) {
  .x <- x
  .x$spdf <- raster::crop(.x$spdf, raster::extent(xmin, xmax, ymin, ymax ))
  .x
}

Try the GADMTools package in your browser

Any scripts or data that you put into this service are public.

GADMTools documentation built on Aug. 5, 2021, 1:06 a.m.