| Title: | Get Mobility Related Data for Portugal |
|---|---|
| Description: | A collection of methods to get mobility related data for Portugal. |
| Authors: | Gonçalo F. Matos [aut, cre] (ORCID: <https://orcid.org/0009-0001-3489-1732>) |
| Maintainer: | Gonçalo F. Matos <[email protected]> |
| License: | GPL |
| Version: | 1.0 |
| Built: | 2026-10-15 11:18:46 UTC |
| Source: | https://github.com/u-shift/mobilitydatapt |
Retrieves Census Origin-Destination (Home/Work & Study) data from INE for a given home location.
census_od(id = "PT")census_od(id = "PT")
id |
Region category filter ID (default |
Refer to INE website to access the indicator online.
A data.frame containing the aggregated Census OD records with columns:
geocod: Home location code
geodsg: Home location designation
dim_3: Sex category code
dim_3_t: Sex category designation (H, M, HM)
dim_4: Employment status code
dim_4_t: Employment status designation (Empregada, Estudante, Total)
dim_5: Working location code
dim_5_t: Working location designation
ind_string: Count / resident population value in string format
valor: Count / resident population value in numeric format
Periodo: Reference period (2011, 2021)
Data source: Instituto Nacional de Estatística (INE) (https://www.ine.pt/xportal/xmain?xpgid=ine_main&xpid=INE).
MobilityDataPT::census_od_regions()
od_data <- MobilityDataPT::census_od(id = "PT") od_data |> dplyr::sample_n(5)od_data <- MobilityDataPT::census_od(id = "PT") od_data |> dplyr::sample_n(5)
Queries the INE metadata API for the available regional filtering options
available for MobilityDataPT::census_od().
census_od_regions()census_od_regions()
A data.frame with columns id and name.
Data source: Instituto Nacional de Estatística (INE) (https://www.ine.pt/xportal/xmain?xpgid=ine_main&xpid=INE).
MobilityDataPT::census_od()
regions <- MobilityDataPT::census_od_regions() head(regions)regions <- MobilityDataPT::census_od_regions() head(regions)
Retrieves spatial coordinates and geometry for specific postal code(s) from the Eurostat GISCO postal code database.
get_postal_code_coordinates( postal_codes = NULL, cntr_id = "PT", year = 2024, crs = 4326, download_dir = NULL )get_postal_code_coordinates( postal_codes = NULL, cntr_id = "PT", year = 2024, crs = 4326, download_dir = NULL )
postal_codes |
Character vector of postal code identifiers (e.g., |
cntr_id |
Two-letter country code to filter by (default |
year |
Release year of the dataset. Allowed values are |
crs |
Coordinate Reference System (EPSG code) of the dataset. Allowed values are |
download_dir |
Directory where downloaded GeoPackage files are stored. Defaults to the
|
An sf object containing matching postal code records and geometries.
Data source: Eurostat GISCO Postal Codes (https://ec.europa.eu/eurostat/web/gisco/geodata/administrative-units/postal-codes).
MobilityDataPT::postal_code_database()
MobilityDataPT::get_postal_code_coordinates(c("1000-001", "2800-001"))MobilityDataPT::get_postal_code_coordinates(c("1000-001", "2800-001"))
Downloads and reads the GISCO Postal Codes dataset provided by Eurostat.
Files are cached locally in the directory specified by the MOBILITYDATAPT_DOWNLOAD_DIRECTORY
environment variable, defaulting to ~/.local/share/R/MobilityDataPT.
postal_code_database( cntr_id = "PT", year = 2024, crs = 4326, download_dir = NULL )postal_code_database( cntr_id = "PT", year = 2024, crs = 4326, download_dir = NULL )
cntr_id |
Two-letter country code to filter by (default |
year |
Release year of the dataset. Allowed values are |
crs |
Coordinate Reference System (EPSG code) of the dataset. Allowed values are |
download_dir |
Directory where downloaded GeoPackage files are stored. Defaults to the
|
An sf object containing spatial postal code boundaries/points.
Returned columns include:
POSTCODE: Postal code identifier (e.g. "1000-001")
CNTR_ID: Country identifier (e.g. "PT")
LAU_NAME: Local Administrative Unit name ("freguesia" for Portugal)
NUTS3_2024: NUTS level 3 region code
Shape: Point of postal code location.
Data source: Eurostat GISCO Postal Codes (https://ec.europa.eu/eurostat/web/gisco/geodata/administrative-units/postal-codes).
db <- MobilityDataPT::postal_code_database() db |> dplyr::select(POSTCODE, LAU_NAME, Shape) |> dplyr::sample_n(5)db <- MobilityDataPT::postal_code_database() db |> dplyr::select(POSTCODE, LAU_NAME, Shape) |> dplyr::sample_n(5)
Encapsulates the calculation functionality of the web service provided by Infraestruturas de Portugal. Queries IP API to calculate expected toll costs across vehicle classes (C1, C2, C3, C4) for a given spatial itinerary.
tools_for_itinerary(sf_itinerary)tools_for_itinerary(sf_itinerary)
sf_itinerary |
An |
A named list containing toll costs in Euros for each vehicle class (C1, C2, C3, C4).
Data source: Infraestruturas de Portugal (https://portagens.infraestruturasdeportugal.pt/). Terms of service apply.
sf_itinerary <- sf::st_read(system.file("extdata/samples", "tool_itinerary_25AbrilBridge.gpkg", package = "MobilityDataPT" ), quiet = TRUE) MobilityDataPT::tools_for_itinerary(sf_itinerary)sf_itinerary <- sf::st_read(system.file("extdata/samples", "tool_itinerary_25AbrilBridge.gpkg", package = "MobilityDataPT" ), quiet = TRUE) MobilityDataPT::tools_for_itinerary(sf_itinerary)