A few months ago, I wanted to map Japanese coordinate data to administrative division levels. To achieve this, I developed a reverse geocoding tool reversejp using administrative boundary data from the Japan Meteorological Agency (JMA). The core functionality is implemented in Rust, and I packaged it as a Python library using PyO3 and Maturin.

Although Japan’s land area is not very large, the JMA dataset subdivides the country into over 3,000 administrative units at its finest level. Considering Japan’s total land area, this results in extremely fine-grained coverage.

The core processing flow scans through all polygons in sequence, checks whether a given point lies within each polygon, and returns the properties of every matching polygon in order.

Example usage in Rust:

1
cargo add reversejp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// https://github.com/ringsaturn/reversejp/blob/main/reversejp-rust/examples/demo.rs
use reversejp::ReverseJp;

fn main() {
    let reverse_jp = ReverseJp::with_embedded_data().unwrap();
    let props = reverse_jp.find_properties(139.7670, 35.6812);

    for prop in props {
        println!("Code: {}, Name: {}, English Name: {}", prop.code, prop.name, prop.en_name);
    }
}

Output:

1
2
Code: 130010, Name: Tokyo Metropolis, English Name: Tokyo
Code: 1310100, Name: Chiyoda Ward, English Name: Chiyoda City

Example usage in Python:

1
pip install reversejp
1
2
3
4
5
6
7
# https://github.com/ringsaturn/reversejp/blob/main/reversejp-python/examples/demo.py
import reversejp

props = reversejp.find_properties(139.7670, 35.6812)

for prop in props:
    print(prop.code, prop.name, prop.en_name)

Output:

1
2
130010 Tokyo Metropolis Tokyo
1310100 Chiyoda Ward Chiyoda City