GeoNamesPincode / README.md
Stratoscale's picture
Add GeoNames postal codes Parquet (1.83M rows, 121 countries) and dataset card
c295d2b verified
|
Raw History Blame Contribute Delete
3.19 kB
---
license: cc-by-4.0
pretty_name: GeoNames Postal Codes (Parquet)
tags:
- geospatial
- postal-codes
- pincode
- geocoding
- geonames
size_categories:
- 1M<n<10M
configs:
- config_name: default
data_files: postal_codes.parquet
---
# GeoNames Postal Codes — Parquet
The [GeoNames postal code dataset](https://download.geonames.org/export/zip/)
(`allCountries.txt`) converted to a single sorted, zstd-compressed Parquet file.
It is used as a postcode → lat/lon lookup table for joining tabular locations
onto gridded weather data (e.g. ERA5 Zarr) in
[zarr-datafusion](https://github.com/stratoscale-io/zarr-datafusion).
| | |
|---|---|
| Rows | 1,826,904 (one row per **place**, not per postcode) |
| Distinct `(country_code, postal_code)` | 1,080,715 |
| Countries | 121 |
| File | `postal_codes.parquet`, ~19 MB, zstd(3), sorted by `country_code, postal_code, place_name` |
| Source snapshot | GeoNames export of 2026-09-22 |
## Schema
| column | type | nullable | notes |
|---|---|---|---|
| `country_code` | string | no | ISO 3166-1 alpha-2 |
| `postal_code` | string | no | text — many countries use letters (`EC1A`, `100-0001`) |
| `place_name` | string | yes | locality / post office |
| `admin_name1` / `admin_code1` | string | yes | state / province |
| `admin_name2` / `admin_code2` | string | yes | county / district |
| `admin_name3` / `admin_code3` | string | yes | community / sub-district |
| `latitude`, `longitude` | float64 | no | WGS84 decimal degrees |
| `accuracy` | int8 | yes | 1 = estimated, 4 = GeoNames place id, 6 = centroid of addresses or shape |
## Caveats
- **One row per place.** A postcode can have many rows (Delhi `110001` has 21);
collapse to one point per `(country_code, postal_code)` before joining.
- **`accuracy` describes the method, not the error.** Countries without published
postal geometry are geocoded by place name. India, for example, has no
accuracy-6 rows, and over 100 Bengaluru `560xxx` pincodes share one fallback
district point ~28 km north of the city centre — including rows marked 4.
- **UK, Canada and the Netherlands** are outward/short codes only here; GeoNames
publishes full codes separately (`GB_full`, `CA_full`, `NL_full`), not included.
## Usage
Direct HTTPS (supports range requests):
```
https://huggingface.co/datasets/Stratoscale/GeoNamesPincode/resolve/main/postal_codes.parquet
```
```python
import duckdb
duckdb.sql("""
SELECT * FROM 'hf://datasets/Stratoscale/GeoNamesPincode/postal_codes.parquet'
WHERE country_code = 'IN' AND postal_code = '110001'
""")
```
## Reproduce
```bash
curl -O https://download.geonames.org/export/zip/allCountries.zip
unzip allCountries.zip allCountries.txt
zarr-cli cookbook/pincode-lookup/build_postcodes.sql
```
## License and attribution
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), the
license of the source data. Contains data from
[GeoNames](https://www.geonames.org/) (© GeoNames, CC BY 4.0). The data is
provided "as is" without warranty of accuracy, timeliness or completeness.
Changes from the source: converted from TSV to Parquet, typed columns, sorted;
no rows added, removed or modified.