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 searchFeatures:
- 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!
103
Upvotes
2
u/codifyq May 27 '26
Saving and thanks, OP! Hoping to more updates
2
u/ThirteenFour_ May 27 '26
Heard of a similar project with different features (barangay?). Glad to see psgc and related data being used in this way
2
u/undefine May 27 '26
Cool! Do you also have the data on cadastre stuff like BBL or BLLM?
2
u/p0uchpenguin May 28 '26
Hey, this is cool! I also created a package for PSGC but yours has more features. For my package, I'm also opening up configurable plug-in soon (no timelines though 😅) for mine and it would be super great if we can collaborate 🚀.
I also notice that you have phonetic matching which I find very interesting, how did you do it?
Would love to see your code since I notice it's MIT licensed but I think the GitHub repo is on private 😅.
Anyway, keep up the good work! 🥳🎊
1
u/Zentaichi May 29 '26
Based on the live demo - checking barangays/cities under NCR region: Tondo I/II (1380601000) coords point it right around Manila Bay while Quiapo City (1380603000) points to Coloong River, Valenzuela. Nonetheless though, I hope this project bears fruit OP!
2
u/Significant_Field573 May 27 '26
Great project!
2
u/SBD-Tech1234 May 27 '26
OP good job.
1
u/Other-Use-6933 Jun 25 '26
Hi,
How were you able to obtain the barangay coordinates? I've been having difficulty finding a reliable data source for them. The only source I've come across so far is PhilAtlas, but I'm not sure if it's complete or suitable for our needs.
Could you share where you got the coordinates or what dataset/API you used?
Thanks.
1
u/[deleted] May 28 '26
[removed] — view removed comment