Datasets:
|
Download README.md from junaid008/pak_cities: direct link, hf CLI and curl.
- Browser
- Download file 11.2 kB
-
https://huggingface.co/datasets/junaid008/pak_cities/resolve/main/README.md
- Command line
-
hf download hf://datasets/junaid008/pak_cities/README.md
-
curl -L -o README.md https://huggingface.co/datasets/junaid008/pak_cities/resolve/main/README.md
11.2 kB
| license: cc-by-4.0 | |
| pretty_name: "Pakistan populated places (GeoNames): location, province, elevation, population" | |
| language: | |
| - en | |
| task_categories: | |
| - tabular-regression | |
| tags: | |
| - pakistan | |
| - pakdata | |
| - tabular | |
| - geography | |
| - cities | |
| - population | |
| - geonames | |
| size_categories: | |
| - n<1K | |
| configs: | |
| - config_name: default | |
| data_files: | |
| - split: train | |
| path: data/train.parquet | |
| # Pakistan populated places (GeoNames): location, province, elevation, population | |
| Part of **[pakdata](https://github.com/junaidaslam2006/pakData)**, a collection of real, openly licensed Pakistan-specific datasets for machine learning. | |
| Every value comes from the named public source below; nothing is synthetic or AI-generated. | |
| | | | | |
| |---|---| | |
| | Rows | 575 | | |
| | Default target | `log_population` (regression) | | |
| | Source | GeoNames (geonames.org daily export PK.zip + admin1CodesASCII.txt) | | |
| | License | CC BY 4.0 | | |
| | Snapshot | 2026.11 | | |
| ## Load it | |
| ```python | |
| # pakdata (scikit-learn style, works offline) pip install pakdata | |
| from pakdata import load_pak_cities | |
| X, y = load_pak_cities(return_X_y=True) | |
| # Hugging Face datasets (also gives PyTorch / TensorFlow / JAX formats) | |
| from datasets import load_dataset | |
| ds = load_dataset("junaid008/pak_cities", split="train") | |
| torch_ds = ds.with_format("torch") | |
| # pandas / Polars / DuckDB, straight from the Hub | |
| import pandas as pd; df = pd.read_parquet("hf://datasets/junaid008/pak_cities/data/train.parquet") | |
| import polars as pl; df = pl.read_parquet("hf://datasets/junaid008/pak_cities/data/train.parquet") | |
| import duckdb; duckdb.sql("SELECT * FROM 'hf://datasets/junaid008/pak_cities/data/train.parquet'") | |
| ``` | |
| **Plain CSV (Excel, R, Julia, MATLAB, SPSS, anything):** | |
| `https://huggingface.co/datasets/junaid008/pak_cities/resolve/main/csv/pak_cities.csv` | |
| ```r | |
| df <- read.csv("https://huggingface.co/datasets/junaid008/pak_cities/resolve/main/csv/pak_cities.csv") | |
| ``` | |
| **JSON API (JavaScript, mobile apps, any language):** | |
| `https://datasets-server.huggingface.co/rows?dataset=junaid008/pak_cities&config=default&split=train&offset=0&length=100` | |
| **Features used by `pakdata`:** `latitude`, `longitude`, `feature_code`, `province`, `elevation_m`, `elevation_source` | |
| **Kept in the table but not used as features** (ids, raw dates, or columns that would leak the target): `geonameid`, `name`, `ascii_name`, `population`, `timezone`, `modification_date`, `pop_shared_with_namesake` | |
| ## Data card | |
| The full data card (column meanings and units, how it was built, caveats, suggested tasks): | |
| ```text | |
| .. _pak_cities_dataset: | |
| Pakistan populated places (GeoNames) | |
| ------------------------------------ | |
| **Data Set Characteristics:** | |
| :Number of Instances: 575 populated places (one row per GeoNames feature) | |
| :Number of Attributes: 6 features (``latitude``, ``longitude``, ``feature_code``, ``province``, ``elevation_m``, ``elevation_source``) + target; 14 columns in ``frame`` | |
| :Default target: ``log_population`` (log10 of persons) | |
| :Time coverage: static gazetteer snapshot; records last modified between 2011-02-08 and 2026-11-27; population figures are of mixed, mostly undated vintage | |
| :Geographic coverage: Pakistan (all 4 provinces, Islamabad Capital Territory, Gilgit-Baltistan, Azad Kashmir); latitude 24.1-36.5 N, longitude 61.6-76.2 E | |
| :Source: GeoNames geographical database, daily export https://download.geonames.org/export/dump/PK.zip and https://download.geonames.org/export/dump/admin1CodesASCII.txt (https://www.geonames.org) | |
| :License: Creative Commons Attribution 4.0 (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/ , as stated in https://download.geonames.org/export/dump/readme.txt and https://www.geonames.org/about.html | |
| :Snapshot: 2026.11 (retrieved 2026-11-29) | |
| **Columns:** | |
| - ``geonameid`` (int): GeoNames feature id (identifier; excluded from features) | |
| - ``name`` (str): place name as in GeoNames, UTF-8 (excluded from features) | |
| - ``ascii_name`` (str): plain-ASCII name (excluded from features) | |
| - ``latitude`` (degrees, WGS84): latitude of the place point | |
| - ``longitude`` (degrees, WGS84): longitude of the place point | |
| - ``feature_code`` (category): GeoNames populated-place code. Counts in this file: | |
| PPL populated place 456, PPLA2 seat of 2nd-order admin division (district) 91, | |
| PPLA seat of 1st-order division (provincial capital) 6, PPLX section of populated place 6, | |
| PPLL locality 4, PPLF farm village 3, PPLA3 2, PPLW destroyed place 2, | |
| PPLQ abandoned place 2, PPLC capital (Islamabad) 1, PPLA4 1, PPLS populated places 1 | |
| - ``province`` (category): province / territory mapped from the GeoNames admin1 code | |
| (PK.02 Balochistan, PK.03 Khyber Pakhtunkhwa, PK.04 Punjab, PK.05 Sindh, | |
| PK.06 Azad Kashmir, PK.07 Gilgit-Baltistan, PK.08 Islamabad, renamed here to | |
| "Islamabad Capital Territory"). Counts: Punjab 285, Sindh 134, Khyber Pakhtunkhwa 77, | |
| Balochistan 49, Azad Kashmir 20, Gilgit-Baltistan 7, Islamabad Capital Territory 3 | |
| - ``population`` (persons): population as recorded in GeoNames (raw; excluded from | |
| features because it determines the target) | |
| - ``log_population`` (log10 persons): ``log10(population)``, the default target (also | |
| listed in ``exclude_from_features``, so it is never a feature when another | |
| population column is chosen as target) | |
| - ``elevation_m`` (m): GeoNames ``elevation`` field when filled (32 rows), otherwise the | |
| GeoNames ``dem`` field (543 rows; SRTM3 ~90 m or GTOPO30 ~900 m average terrain height | |
| around the point) | |
| - ``elevation_source`` (category): ``elevation`` or ``dem``, which GeoNames field ``elevation_m`` came from | |
| - ``timezone`` (str): IANA timezone; ``Asia/Karachi`` for every row (excluded from features as constant) | |
| - ``modification_date`` (date): date the GeoNames record was last modified (excluded from features) | |
| - ``pop_shared_with_namesake`` (bool): True when another row with the same ``ascii_name`` | |
| has exactly the same ``population`` (8 rows, 4 pairs; see caveats). Computed by pakdata | |
| from the source values; it is derived from ``population`` and is excluded from features | |
| **How it was built:** ``scripts/build_pak_cities.py`` downloads PK.zip (all ~230,000 | |
| GeoNames features for Pakistan) and admin1CodesASCII.txt, keeps rows with feature class | |
| ``P`` (populated places) and population > 0, maps the admin1 code to the province name, | |
| computes ``log_population = log10(population)``, builds ``elevation_m`` from ``elevation`` | |
| falling back to ``dem`` (DEM value -9999 would be treated as missing; none occurred), | |
| flags ``pop_shared_with_namesake``, rounds coordinates to 5 decimals and sorts rows by | |
| ``geonameid``. No values were imputed; | |
| in this snapshot no column has missing values. | |
| **Caveats and known biases:** | |
| - GeoNames populations are NOT the 2023 Pakistan census (nor any single census). They come | |
| from many contributors and sources of uneven vintage and accuracy; some are city-proper, | |
| some metropolitan, some rounded estimates (e.g. Malir Cantonment 300000), and a few very | |
| small values (4-14 persons) are user-added entries such as havelis or farmsteads. | |
| Use them for ML practice, not for demographic statements. | |
| - Strong selection bias: only 575 of about 150,000 populated places (feature class P; | |
| 150,406 of the 229,987 features in this PK.txt snapshot) have a population filled in. Larger towns and district seats | |
| are heavily over-represented, so the data is not a random sample of settlements. | |
| - Some population figures appear to be copied between different, same-named places in | |
| GeoNames, so a few rows are wrong at the source (pakdata keeps the source values | |
| unchanged). Pairs in this snapshot: Sahiwal 1166548 (PPLA2, district city, 30.67 N) | |
| and Sahiwal 1166547 (small town in Sargodha district, 31.97 N) both carry 538344; | |
| Bahawalnagar 1183883 (PPLA2) and 1332083 (PPL, 30.55 N) both carry 241873; | |
| Talagang 1164069 and 1335232 (33.07 N 71.93 E) both carry 79431; Noorabad 1453226 | |
| (Khyber Pakhtunkhwa) and 11027195 (Sindh) both carry 1100. These rows are marked by | |
| ``pop_shared_with_namesake``; consider dropping them, or at least the smaller | |
| non-seat member of each pair, e.g. | |
| ``df = df[~df.pop_shared_with_namesake]``. Some other figures describe a tehsil or | |
| metropolitan area rather than the town itself (e.g. Chunian 634236). | |
| - Coverage is very uneven by region (Punjab 285 rows vs Gilgit-Baltistan 7, ICT 3). | |
| - ``elevation_source == "elevation"`` rows are mostly recently hand-added small places, so | |
| that column partly encodes "who entered the record" rather than geography. | |
| - Includes a few sections of cities (PPLX, e.g. Wah Cantt, Malir Cantonment) and destroyed | |
| or abandoned places (PPLW, PPLQ) whose population figures may be historical. Places can | |
| overlap (a PPLX section inside a city is counted separately from that city). | |
| - Coordinates are single points (often the town centre); DEM elevation is an area average. | |
| - GeoNames is a crowd-edited wiki; rerunning the build script later may give different rows. | |
| **Suggested tasks:** | |
| 1. Regression: predict ``log_population`` from location, elevation, province and | |
| ``feature_code``; compare LinearRegression with a RandomForest (5-fold CV R^2 is about | |
| 0.26 and 0.31 respectively in this snapshot, so the task is hard and not leaked). | |
| 2. Classification: ``load_pak_cities(target="province")`` and predict the province from | |
| coordinates (plus elevation); a RandomForest reaches roughly 0.94 accuracy vs a 0.50 | |
| majority baseline. Visualise the decision boundaries on a lat/long plot. | |
| 3. Clustering: run k-means or DBSCAN on ``latitude``/``longitude`` (optionally weighted by | |
| population) and compare clusters with provinces. | |
| 4. Exploration: plot rank vs population on log-log axes to check Zipf's law for Pakistani | |
| cities, and discuss how the selection bias above affects the result. | |
| **Citation / attribution:** GeoNames geographical database (https://www.geonames.org), | |
| Pakistan export PK.zip and admin1CodesASCII.txt, retrieved 2026-11-29. Licensed under the | |
| Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/). | |
| Data provided "as is" without warranty or any representation of accuracy, timeliness or | |
| completeness. Modified by pakdata: filtered to populated places with population > 0, | |
| province names mapped from admin1 codes, log10 population and merged elevation column added. | |
| ``` | |
| ## Citation and attribution | |
| GeoNames geographical database (https://www.geonames.org), Pakistan export PK.zip and admin1CodesASCII.txt, retrieved 2026-11-29. Licensed under the Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/). Data provided "as is" without warranty or any representation of accuracy, timeliness or completeness. Modified by pakdata: filtered to populated places with population > 0, province names mapped from admin1 codes, log10 population and merged elevation column added. | |
| Packaged by pakdata (https://github.com/junaidaslam2006/pakData). Build script: [`scripts/build_pak_cities.py`](https://github.com/junaidaslam2006/pakData/blob/main/scripts/build_pak_cities.py). | |