mosaic_files: Stitches together files into a single raster Requires a...

Description Usage Arguments Value Examples

View source: R/mosaic_files.R

Description

Stitches together files into a single raster Requires a target directory of files that can be read with raster::raster(), e.g. .asc files, or a directory of .zip files containing these files

Usage

1
2
3
4
5
6
7
8
9
mosaic_files(
  path,
  extract_zip = FALSE,
  file_match = ".*.asc",
  zip_file_match = ".*.zip",
  raster_output_file = "mosaic_out.raster",
  file_crs = NULL,
  raster_todisk = FALSE
)

Arguments

path

path to files that are to be stitched together

extract_zip

FALSE to target .asc files, TRUE if your .asc files are zipped.

file_match

regex pattern to match .asc files, either in path or in zip files.

zip_file_match

regex pattern to match .zip files

raster_output_file

raster file to be created (will overwrite existing files)

file_crs

projection string of the input files. Output will always be WGS84.

raster_todisk

Setting TRUE will set rasterOptions(todisk=TRUE), which can help with memory issues.

Value

TRUE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Merges two small example .asc files of LIDAR data
# from https://environment.data.gov.uk (open government licence)

path_to_files <- system.file("extdata/example_asc", package = "geoviz")

path_to_output <- tempdir()

mosaic_files(path_to_files,
             raster_output_file = paste0(path_to_output, '/mosaic_out.raster', sep = ''),
             extract_zip = TRUE, file_crs = "+init=epsg:27700")

raster_mosaic <- raster::raster(paste0(path_to_output, '/mosaic_out.gri', sep = ''))

Example output

Unzipping files...
Merging files...
sh: 1: awk: Permission denied
Done
[1] TRUE
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum OSGB_1936 in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Unknown based on Airy 1830 ellipsoid in CRS definition
3: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Unknown based on Airy 1830 ellipsoid in CRS definition
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Unknown based on Airy 1830 ellipsoid in CRS definition

geoviz documentation built on March 26, 2020, 9:15 p.m.