GDAL_crop: Crop raster

Description Usage Arguments Value Examples

View source: R/GDAL_crop.R

Description

The function crops rasters (to the shapefile boundary) using GDAL. Use only filepaths (not rasters/shapefiles loaded in R environment).

Usage

1
2
GDAL_crop(input_raster, filename, shapefile_path, large_tif = FALSE,
  return_raster = TRUE)

Arguments

input_raster

Character. Raster to be cropped (file path or Raster object). Input raster should be stored on disk for GDAL access.

filename

Character. Output raster path.

shapefile_path

Character. Filepath of a shapefile or geopackage. that is used to crop the raster. Disk path, not sp or sf object.

large_tif

Logical. Use large_tif = TRUE for large rasters (>4GB).

return_raster

Logical. The function stores the raster in the filename argument path as a side-effect.

Value

Raster object. Only if return_raster = TRUE. Otherwise, the function side-effect is to save the file locally.

Examples

1
2
3
4
5
6
7
8
library(gdalR)
library(Rahat)

we_eu <- milkunize("Projects/Land_use/Data/Shapefile/IMAGE_regions/Individual_regions/Western_Europe_IMAGE.shp")
dem <- milkunize("Merit_DEM_10s.tif", "m5")

# Crop dem
dem_cropped <- GDAL_crop(dem, filename = "/vol/milkun1/Mirza_Cengic/Temp/dem_we.tif", shapefile_path = we_eu)

MirzaCengic/gdalR documentation built on July 26, 2019, 11:36 p.m.