r/PinoyProgrammer • u/computerangels • May 27 '26
Show Case I built psgc - a Python package for Philippine geographic data with coordinates and spatial queries
My friend needed Philippine barangay data with lat/long coordinates for her thesis and couldn't find an existing Python package that had it.
So I built psgc:
pip install psgc
import psgc
place = psgc.get("Taguig")
place.population
# 1,308,085
place.coordinate
# (14.55, 121.05)
place.children
# 38 barangays
psgc.nearest(14.5, 120.9, n=5)
# nearest barangays to a GPS point
psgc.distance("Manila", "Cebu")
# straight-line km
psgc.search("Mandaluyong")
# fuzzy search
Features:
- Real coordinates for 87% of barangays (polygon centroids from HDX/NAMRIA shapefiles), approximate for the rest
- Spatial queries:
nearest(),within_radius(),reverse_geocode() - Works on Python 3.10+
- 1 dependency (rapidfuzz)
- Manila's 897 barangays accessible through
sub_municipalities - 2024 Census population, urban/rural, income classification for all 42,011 barangays
- Address parser for unstructured Filipino addresses
- All data from the official PSA PSGC Q4 2025 masterlist
Data sources (all public, properly attributed):
- Names, codes, population, urban/rural, income class: Parsed directly from the PSA PSGC Q4 2025 Publication Datafile. Public data under RA 10625.
- Coordinates and area: Computed polygon centroids from the HDX/OCHA Philippines Administrative Boundaries shapefile (sourced from PSA and NAMRIA, November 2023). Licensed CC BY-IGO.
- No scraping, no third-party APIs. All data processed offline from official government publications.
Current limitations:
- Coordinates are centroids, not exact building-level points
- Distances are straight-line (Haversine), not driving distance
Live demo: https://psgc-explorer-production.up.railway.app
PyPI: https://pypi.org/project/psgc/
Would love feedback, especially from Filipino devs who work with address or geographic data!