Psgc
A Ruby gem providing up-to-date Philippine geographic data from the PSA (Philippine Statistics Authority). Includes Philippine Standard Geographic Codes (PSGC) for regions, provinces, cities/municipalities, and barangays.
Installation
gem install psgc-rb
Or add to Gemfile:
gem "psgc-rb"
Usage
require "psgc"
# Get all regions
Psgc.regions
# => [{:code=>"1300000000", :name=>"National Capital Region (NCR)"}, ...]
# Get all provinces
Psgc.provinces
# => [{:code=>"1400100000", :name=>"Abra", :region_code=>"14"}, ...]
# Get all cities and municipalities
Psgc.cities_municipalities
# => [{:code=>"1400101000", :name=>"Bangued", :province_code=>"1400"}, ...]
# Get all barangays
Psgc.
# => [{:code=>"1400101001", :name=>"Bagtayan", :city_municipality_code=>"1400101000"}, ...]
Data Source
Data is sourced from the PSA PSGC Publication Datafile, released quarterly.
- URL: https://psa.gov.ph/classification/psgc/
- Current data: 1Q 2026
To update data:
- Download the latest Excel file from PSA
- Run
rake "data:parse[path/to/file.xlsx]" - Commit the updated JSON files
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.
License
The gem is available as open source under the terms of the MIT License.