spod_duckdb_number_of_trips: Create a duckdb number of trips table

View source: R/duckdb-helpers.R

spod_duckdb_number_of_tripsR Documentation

Create a duckdb number of trips table

Description

This function creates a duckdb connection to the number of trips data stored in a folder of CSV.gz files.

Usage

spod_duckdb_number_of_trips(
  con = DBI::dbConnect(duckdb::duckdb(), dbdir = ":memory:", read_only = FALSE),
  zones = c("districts", "dist", "distr", "distritos", "municipalities", "muni",
    "municip", "municipios", "lua", "large_urban_areas", "gau", "grandes_areas_urbanas"),
  ver = NULL,
  data_dir = spod_get_data_dir()
)

Arguments

con

A duckdb connection object. If not specified, a new in-memory connection will be created.

zones

The zones for which to download the data. Can be "districts" (or "dist", "distr", or the original Spanish "distritos") or "municipalities" (or "muni", "municip", or the original Spanish "municipios") for both data versions. Additionaly, these can be "large_urban_areas" (or "lua", or the original Spanish "grandes_areas_urbanas", or "gau") for v2 data (2022 onwards).

ver

Integer. Can be 1 or 2. The version of the data to use. v1 spans 2020-2021, v2 covers 2022 and onwards.

data_dir

The directory where the data is stored. Defaults to the value returned by spod_get_data_dir().

Value

A duckdb connection object with 2 views:

  • od_csv_raw - a raw table view of all cached CSV files with the origin-destination data that has been previously cached in $SPANISH_OD_DATA_DIR

  • od_csv_clean - a cleaned-up table view of od_csv_raw with column names and values translated and mapped to English. This still includes all cached data.


spanishoddata documentation built on April 12, 2025, 1:24 a.m.