bangladesh-geocode

Logo

Division, District, Upazila and, Union level fully mapped Dataset in SQL, CSV, JSON, XML, and PHP format.

View the Project on GitHub nuhil/bangladesh-geocode

Bangladesh GeoCode

Division, District, Upazila, Union, City Corporation and Post Office / Postcode level, fully mapped database of Bangladesh. Import the files into your DB and join them to get the geo information you need.

The data is generated by a small, reproducible pipeline (pipeline/). It combines official Bangladesh Bureau of Statistics (BBS) geocodes with the original hand-collected data of this repository, so every record keeps its Bangla name and website and also gains an official code and coordinates.

Administrative hierarchy

Division (8)
└── District (64)
    ├── Upazila (495)
    │   └── Union (4,540)
    ├── City Corporation (12)          e.g. Dhaka North, Dhaka South, Chattogram, Gazipur …
    └── Post office / postcode (1,349) linked to an upazila OR a city corporation

For example, Dhaka district has 5 upazilas (Savar, Dhamrai, Keraniganj, Nawabganj, Dohar), each with its unions. The urban area belongs to the Dhaka North and Dhaka South City Corporations, and their post offices (Dhaka GPO 1000, Gulshan Model Town 1212, Mirpur 1216 …) are linked with postcodes.city_corporation_id.

Tables and columns

The CSV files have no header row. Their columns are in the order listed below. The columns that existed before are unchanged and in the same position, and new columns are appended at the end, so existing integrations keep working. bbs_code, lat and lon may be empty when a record could not be matched to an official source.

Table Columns
divisions id, name, bn_name, url, bbs_code, lat, lon
districts id, division_id, name, bn_name, lat, lon, url, bbs_code
upazilas id, district_id, name, bn_name, url, bbs_code, lat, lon
unions id, upazilla_id, name, bn_name, url, bbs_code, lat, lon
city_corporations (new) id, division_id, district_id, name, bn_name, url, bbs_code, lat, lon
postcodes (new) id, division_id, district_id, upazila_id, city_corporation_id, thana, post_office, postcode, lat, lon, link_method

Available formats

Each table has its own folder (for example unions/) containing:

database/bd_geo_code.sql contains all tables in a single file, with foreign keys.

GeoJSON district boundaries are available in geojson/districts.geojson.

Data sources

Source Used for Licence
Bangladesh Bureau of Statistics (BBS) geocodes, published as the Bangladesh Subnational Administrative Boundaries (COD-AB) dataset by UN OCHA on the Humanitarian Data Exchange Official names, BBS codes, coordinates and boundaries for divisions, districts, upazilas and the 12 city corporations; union reference points CC BY-IGO
GeoNames postal code dump for Bangladesh (BD.zip), compiled from the Bangladesh Post Office postcode list Post offices and postcodes CC BY 4.0
Original collection of this repository (2019), from bangladesh.gov.bd (the national portal), wikipedia.org and maps.google.com Bangla names, official *.gov.bd website addresses, DC office coordinates, the union list as this repository
City corporation websites (*.gov.bd), checked by hand City corporation Bangla names and URLs (pipeline/manual/city_corporations.csv) public information

The exact download URLs, retrieval dates, dataset versions and checksums of the last update are recorded in pipeline/sources/manifest.json.

Name spelling: English names of divisions, districts and upazilas follow the official BBS spelling, for example Chattogram, Barishal, Cox’s Bazar, Bogura Sadar, and Indurkani (formerly Zianagar). The full list of matches is in pipeline/reports/. Union names keep the spelling used by each union parishad’s own website.

How the data is updated

pipeline/
├── fetch_sources.py   download the sources → normalised snapshots in pipeline/sources/
├── build.py           legacy + snapshots + manual edits → every published file
├── legacy/            the original dataset (fallback layer, never overwritten)
├── sources/           committed snapshots of the upstream data + manifest.json
├── manual/            hand-curated corrections (the ONLY place to edit data by hand)
├── state/             stable id registry
└── reports/           build report, unmatched and low-confidence records to review
pip install -r pipeline/requirements.txt   # only needed for fetching
python pipeline/fetch_sources.py           # refresh the upstream snapshots
python pipeline/build.py                   # regenerate all CSV/JSON/SQL/PHP/XML files

A GitHub Action (.github/workflows/data.yml) does two jobs:

Fallbacks

Each layer falls back to the one below it, so a broken or unreachable source never removes data:

  1. A fresh download from HDX / GeoNames.
  2. The last downloaded copy (pipeline/.cache/). If neither is available, the committed snapshot in pipeline/sources/ is kept.
  3. The original data (pipeline/legacy/):
    • A record that cannot be matched to an official source is still published with its original values.
    • Bangla names, websites and DC-office coordinates always come from here.
    • If no snapshots exist at all, the build produces exactly the original dataset.

Contributing corrections

Please do not edit the generated files (divisions/, districts/, upazilas/, unions/, city_corporations/, postcodes/, database/) by hand. They are overwritten by every build, and CI rejects hand edits. Instead, edit one of the CSV files in pipeline/manual/:

File Use it to
overrides.csv Correct one field of any record (table,key,field,value,note). key is a bbs_code or id:<id>. For example, set a Bangla name or a new website.
aliases.csv Pin a legacy upazila or union to its BBS code when the automatic name matching is wrong or missing (table,legacy_id,bbs_pcode,note).
additions.csv Add an upazila or union that is in no source (table,parent_key,name,bn_name,url,lat,lon,note). parent_key is the parent’s id or bbs_code.
postcode_additions.csv Add a post office (district_id,upazila_id,city_corporation_id,thana,post_office,postcode,lat,lon).
city_corporations.csv Set the Bangla names and websites of city corporations.

Then run python pipeline/build.py and open a pull request with both the manual file and the regenerated output. Records that need a human eye are listed in pipeline/reports/:

Please create a pull request to add, update, or delete any records!

Upcoming columns

Now Accepting

❤️ Paypal Donation

Contact

Feel free to find and contact me at Nuhil.net