Skip to contents

Philippine Standard Geographic Code (PSGC)

Usage

get_psgc(
  ...,
  token = NULL,
  version = NULL,
  level = NULL,
  harmonize = TRUE,
  minimal = TRUE,
  cols = NULL
)

Arguments

...

See ?dplyr::filter. Expressions that return a logical value, and are defined in terms of the variables in returned data. If multiple expressions are included, they are combined with the & operator. Only rows for which all conditions evaluate to TRUE are kept.

token

Character. API access token. If NULL, retrieves data from the local cache.

version

Character. PSGC version such as: "Q3_2025", "July_2025", "Q2_2025", "Q1_2025", "April_2024", "Q4_2024", "Q3_2024", "Q2_2024", and "Q4_2023", "Q2_2021". If NULL, retrieves the latest version available in the local cache.

level

Character. Level of geographic data to retrieve. Available options are: "all", "regions", "provinces", "hucs" "municipalities", "sub_municipalities" "barangays", "income_classification", "urban_rural", and "city_class".

harmonize

Logical. If TRUE, formats and standardizes the returned data. Default is TRUE.

minimal

Logical. If TRUE, returns a simplified dataset. Default is TRUE.

cols

Optional. Character vector of additional columns to include when minimal = FALSE.

Value

A data frame of PSGC geographic data.

Examples

if (FALSE) { # \dontrun{
get_psgc(token = "your_api_token")
} # }

# If token is not provided, the function will fetch from local cache or
# download the latest version from remote repo
psgc <- get_psgc()

# Get specific level
psgc_regions <- get_psgc(level = "regions")
psgc_regions
#> # A tibble: 18 × 3
#>    area_code  area_code_old area_name                                           
#>    <chr>      <chr>         <chr>                                               
#>  1 0100000000 010000000     Region I (Ilocos Region)                            
#>  2 0200000000 020000000     Region II (Cagayan Valley)                          
#>  3 0300000000 030000000     Region III (Central Luzon)                          
#>  4 0400000000 040000000     Region IV-A (CALABARZON)                            
#>  5 0500000000 050000000     Region V (Bicol Region)                             
#>  6 0600000000 060000000     Region VI (Western Visayas)                         
#>  7 0700000000 070000000     Region VII (Central Visayas)                        
#>  8 0800000000 080000000     Region VIII (Eastern Visayas)                       
#>  9 0900000000 090000000     Region IX (Zamboanga Peninsula)                     
#> 10 1000000000 100000000     Region X (Northern Mindanao)                        
#> 11 1100000000 110000000     Region XI (Davao Region)                            
#> 12 1200000000 120000000     Region XII (SOCCSKSARGEN)                           
#> 13 1300000000 130000000     National Capital Region (NCR)                       
#> 14 1400000000 140000000     Cordillera Administrative Region (CAR)              
#> 15 1600000000 160000000     Region XIII (Caraga)                                
#> 16 1700000000 170000000     MIMAROPA Region                                     
#> 17 1800000000 NA            Negros Island Region (NIR)                          
#> 18 1900000000 150000000     Bangsamoro Autonomous Region In Muslim Mindanao (BA…