Learn R Programming

MCI2 (version 1.1.2)

tcmat.create: Creation of a transport costs matrix

Description

Creation of a transport costs matrix (airline distance, car travel time)

Usage

tcmat.create(origins.id, origins.addr, 
destinations.id, destinations.addr, 
tc.type = "airline", tc.unit = "km", 
or.addr.format = "stradr", de.addr.format = "stradr",
tc.constant = 0, query.delay = 0, show_proc = FALSE)

Arguments

origins.id

ID of the origins

origins.addr

Address of the origins, either street addresses (e.g. "Markgrafenstrasse 68, Freiburg, Germany") or coordinates (X_LON;X_LAT, e.g.: "7,82218;47,99387")

destinations.id

ID of the destinations

destinations.addr

Address of the destinations, either street addresses (e.g. "Markgrafenstrasse 68, Freiburg, Germany") or coordinates (X_LON;X_LAT, e.g.: "7,82218;47,99387")

tc.type

Type of transportat costs: "airline" (airline distance) or "street" (car travel time)

tc.unit

If tc.type = "airline": unit of distance ("m", "km" or "miles")

or.addr.format

Origins address format. Default: "stradr" (street addresses))

de.addr.format

Destinations address format. Default: "stradr" (street addresses))

tc.constant

Adding a constant to the calculated/queried values (default: 0)

query.delay

Delay within OSM geocoding querys (unit: seconds, default: 0)

show_proc

Logical argument that indicates if the function prints messages about the state of process during the work

Value

A tcmat list (invisible) containing the following components:

coords_origins

A data.frame containing the coordinates (lat, lon) of the origins

coords_destinations

A data.frame containing the coordinates (lat, lon) of the destinations

tcmat

A data.frame containing the transport costs matrix

tc.mode

A list containing information about the transportation costs matrix

Details

Creation of a tcmat list object (Transport costs matrix) for further use in huff and mcimat.create. Included geocoding of street addresses (from geocode_OSM in tmaptools) and travel time query (from ormsTable in osrm) or the calculation of airline distances (from dist.mat in REAT).

References

Giraud, T. (2018): osrm: Interface Between R and the OpenStreetMap-Based Routing Service OSRM. R package version 3.1.1. https://CRAN.R-project.org/package=osrm.

Tennekes, M. (2018): tmaptools: Thematic Map Tools. R package version 2.0-1. https://CRAN.R-project.org/package=tmaptools.

Wieland, T. (2017): “Market Area Analysis for Retail and Service Locations with MCI”. In: The R Journal, 9, 1, p. 298-323. https://journal.r-project.org/archive/2017/RJ-2017-020/RJ-2017-020.pdf.

Wieland, T. (2018): “Competitive locations of grocery stores in the local supply context - The case of the urban district Freiburg-Haslach”. In: European Journal of Geography, 9, 3, p. 98-115.

Wieland, T. (2019): REAT: Regional Economic Analysis Toolbox. R package version 3.0.0. https://CRAN.R-project.org/package=REAT.

See Also

huff, mcimat.create

Examples

Run this code
# NOT RUN {
data(HaslachSurvey)
# survey raw data (Store choices and purchases)
data(HaslachDistricts)
# IDs and information about customer origins
data(HaslachStores)
# IDs and information about destinations (grocery stores)

# }
# NOT RUN {
tcmat_haslach_airline <- tcmat.create(origins.id = HaslachDistricts$WO, 
origins.addr = HaslachDistricts$WO_Adr, destinations.id = HaslachStores$LM, 
destinations.addr = HaslachStores$LM_Adr_zus, 
tc.type = "airline", tc.unit = "km",
addr.format = "stradr", tc.constant = 0, show_proc = TRUE)
# Creation of a transport costs matrix with airline distances
# saving as list object "tcmat_haslach_airline"
# Needs internet access and accesses OpenStreetMap server(s)
# If server not available, the function will produce an error

tcmat_haslach_drvtime <- tcmat.create(origins.id = HaslachDistricts$WO, 
origins.addr = HaslachDistricts$WO_Adr, destinations.id = HaslachStores$LM, 
destinations.addr = HaslachStores$LM_Adr_zus,
tc.type = "street", addr.format = "stradr", 
tc.constant = 0, show_proc = TRUE)
# Creation of a transport costs matrix with car driving times
# saving as list object "tcmat_haslach_drvtime"
# Needs internet access and accesses OpenStreetMap server(s)
# If server not available, will produce an error
# }

Run the code above in your browser using DataLab