subset_layer.Rd
Function to subset and clip a GIS vector or raster layer by a bounding box or clip/subset layer (e.g. shapefile/KML)
subset_layer(
file,
coords = NULL,
sub.layer = NULL,
clip = FALSE,
out.dir = NULL,
out.name = NULL
)
input file to be subset
vector with xmin,ymin,xmax,ymax defing the bounding box for subset
Vector layer defining the subset region
clip geometries to bounding box/subset layer? TRUE/FALSE
output directory for subset layer. Defaults to location of input file. Can also set to 'pwd'
filename for subset layer. Defaults to original filename with the suffix *.sub
if (FALSE) { # \dontrun{
# Test dataset
file <- Sys.glob(file.path(R.home(), 'library', 'PEcAn.data.land','data','*.shp'))
out.dir <- path.expand('~/temp')
# with clipping enabled
subset_layer(file=file,coords=c(-95,42,-84,47),clip=TRUE,out.dir=out.dir)
# without clipping enables
subset_layer(file=file,coords=c(-95,42,-84,47),out.dir=out.dir)
system(paste('rm -r',out.dir,sep=''))
} # }