This function is used by the mapper
functions to load input files and
prepare them for analysis. It can also be used to load input files
independently for plotting with flow_plot
and/or
trouble-shooting.
load_file(
file,
nrow = NULL,
ncol = NULL,
missing_value = -9999,
rlim = NULL,
clim = NULL,
grid = NULL,
min_x = 1,
min_y = 1,
edge = TRUE,
quiet = FALSE,
verbose = TRUE
)
Character. The location of the file containing elevation data. See details for accepted file types
Numeric. Number of rows in dem file (required for dbf files with a single column, but can be automatically assessed from files with x and y coordinates.
Numeric. Number of columns in dem file (required for dbf files with a single column, but can be automatically assessed from files with x and y coordinates.
Vector. The number or character string specifying missing data.
Vector. Two numbers specifying the start and end of a subset of rows to extract
Vector. Two numbers specifying the start and end of a subset of columns to extract
Numeric. Grid size in m of the input DEM file
Numeric. Starting x coordinate (in meters)
Numeric. Starting y coordinate (in meters)
Logical. Whether to add an edge (buffer) around the data.
Logical. Suppress all messages.
Logical. Output extra progress messages.
Returns a data frame containing elevation data in a format suitable for analysis
All x/y data must be in a format such that greater values indicate East or North respectively.
This function uses file extensions to guess the file type to be loaded.
dBase files:
These files are loaded via the read.dbf
function from
the foreign package. Columns must be named and must have a valid name (case
doesn't not matter). X/Y coordinates are optional and must be named as "x",
"lon", "long", "longitude", or "y", "lat", "latitude". Elevation columns can
be "elev", "elevation", or "z". If no "x" and "y" columns are suppled,
nrow
and ncol
arguments must be supplied. Column names matter,
column order does not. Extra columns, if present, are ignored.
dBase files (.dbf)
Grid file types:
These file types are loaded via the raster
function.
Surfer grid files (.grd)
Esri grid files (binary .adf or ascii .asc)
Geo Tiff (.tif)
Floating point raster files (.flt) (Note the companion header, .hdr, file must also be present)
Text/Spreadsheet file types: Data in these files are all assumed to be arranged in three columns reflecting x, y, and z dimensions (z = elevation). Column order is important. Column names don't matter, but they should be present.
Text files (.txt, .dat, .csv) are loaded via R base
link[utils]{read.table}
function.
Excel files (.xls, .xlsx) are loaded via the
read_excel
function.