spod_quick_get_od | R Documentation |
This function provides a quick way to get daily aggregated (no hourly data) trip counts per origin-destination municipality from v2 data (2022 onward). Compared to spod_get, which downloads large CSV files, this function downloads the data directly from the GraphQL API. An interactive web map with this data is available at https://mapas-movilidad.transportes.gob.es/ No data aggregation is performed on your computer (unlike in spod_get), so you do not need to worry about memory usage and do not have to use a powerful computer with multiple CPU cores just to get this simple data. Only about 1 MB of data is downloaded for a single day. The limitation of this function is that it can only retrieve data for a single day at a time and only with total number of trips and total km travelled. So it is not possible to get any of the extra variables available in the full dataset via spod_get.
spod_quick_get_od(
date = NA,
min_trips = 100,
distances = c("500m-2km", "2-10km", "10-50km", "50+km"),
id_origin = NA,
id_destination = NA
)
date |
A character or Date object specifying the date for which to retrieve the data. If date is a character, the date must be in "YYYY-MM-DD" or "YYYYMMDD" format. |
min_trips |
A numeric value specifying the minimum number of journeys per origin-destination pair to retrieve. Defaults to 100 to reduce the amount of data returned. Can be set to 0 to retrieve all data. |
distances |
A character vector specifying the distances to retrieve. Valid values are "500m-2km", "2-10km", "10-50km", and "50+km". Defaults to |
id_origin |
A character vector specifying the origin municipalities to retrieve. If not provided, all origin municipalities will be included. Valid municipality IDs can be found in the dataset returned by |
id_destination |
A character vector specifying the target municipalities to retrieve. If not provided, all target municipalities will be included. Valid municipality IDs can be found in the dataset returned by |
A tibble
containing the flows for the specified date, minimum number of journeys, distances and origin-destination pairs if specified. The columns are:
The date of the trips.
The origin municipality ID.
The target municipality ID.
The number of trips between the origin and target municipality.
The total length of trips in kilometers.
od_1000 <- spod_quick_get_od(
date = "2022-01-01",
min_trips = 1000
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.