multi_ts | R Documentation |
Function that allows to handle different travel scenarios for different administrative units. It creates an updated merged landcover and an updated travel scenario table. The required inputs are an administrative shapefile, a merged landcover imported from AccessMod, and an Excel (or CSV) table for each travel scenario. The function requires a folder that only contains the required inputs. When running the function, the user is asked to select the attribute table column of the shapefile that refers to each administrative unit, and then to select the travel scenario for each administrative unit.
multi_ts(
inputFolder,
adminLayerName,
landcoverFile,
zones_ts = NULL,
outputFolder = NULL
)
inputFolder |
character; the path to the input folder, which must contains an administrative unit shapefile, a merged landcover imported from AccessMod and an Excel or CSV table for each travel scenario. |
adminLayerName |
character; the name of the administrative unit layer (without extension) |
landcoverFile |
character; the file name of the original merged landcover (with extension) |
zones_ts |
character; path to Excel or CSV table (must be outside the input folder) that relates the administrative units to the different scenarios. Two columns: the first one has the same name than the field name of the administrative layer attribute table that refers to each administrative unit, and the second one called 'scenario'. In the first all the different units (as indicated in the attribute table), in the second, the names (without the extension) of the different scenario tables. If set to NULL, the user is interactively asked to assign a scenario to each administrative unit, and a zones_ts table is created. |
outputFolder |
character; the path to the output folder. If NULL, an output folder will be created within the inputFolder. |
An output folder called out is created within the input folder, as well as a subfolder whose name is based on the system time that contains three outputs (e.g. ./out/20220826104842):
The updated landcover raster
The updated travel scenario table
A table that relates the different administrative units to the different travel scenarios
The function works are the following:
Check of the tables that are in the input folder: missing data, column names, values available for all landcover classes, values for the "mode" column, only one value per class, and speed in numerical format and positive or equal to zero.
Console printing of the shapefile attribute table, and selection of the column used to determine the administrative unit.
Interactive selection of the scenario (based on the table names) for each administrative unit, and creation of a table that relates the units and the scenarios, or loading this table if indicated.
Loop over each administrative unit
Copy of the corresponding travel scenario table
Reclassification (sequentially, taking into account the last value assigned for the scenario of the previous unit)
Append the administrative unit name (or code) to the classes' labels
Landcover raster clip and reclassification of the raster values (consistent with the previous reclassification)
Save the new raster (in a temporary directory), save the new table (in a list)
Merging of the rasters of each unit (in case of overlap, the values get priority in the same order as the arguments), and merging of the tables of each unit.
Writing the final raster, the final table, and the table that relates the different administrative units and the different travel scenarios. The final number of classes are N-classes x N-units.
# Replace "outDir" with the actual path to your outputFolder
## Not run:
outputFolder <- "outDir"
inputPathMulti <- system.file("extdata", "multi_ts_example", package="inAccessMod")
multi_ts(inputPathMulti, "admin", "raster_land_cover_merged.img", zones_ts = NULL, outputFolder = outputFolder)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.