File size: 3,192 Bytes
2cf6dfa
c295d2b
 
 
 
 
 
 
 
 
 
 
 
 
2cf6dfa
c295d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
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.