1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

日本行政区画リバースジオコーディング

Posted at

reversejp.png

数ヶ月前、私は日本の座標データを行政区画レベルにマッピングする作業をしたいと思いました。そこで、日本気象庁(JMA)の行政区画データを利用して、リバースジオコーディングツール reversejp を書きました。コア部分のコードはRustで実装し、PyO3とMaturinを使ってPythonパッケージ化しました。

日本の国土面積はそれほど広くありませんが、JMAのデータでは最も細かいレベルで3000以上の行政区画に区分されています。日本の国土面積を考慮すると、実際には非常に精緻です。

データ処理のコアフローは、すべてのポリゴンを順に走査し、指定した点がポリゴン内部にあるかを判定し、条件を満たすポリゴンの情報を順番に返す、というものです。

Rustでの使用例は以下の通りです。

cargo add reversejp
// 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);
    }
}

出力結果:

Code: 130010, Name: 東京都, English Name: Tokyo
Code: 1310100, Name: 千代田区, English Name: Chiyoda City

Pythonでの使用例は以下の通りです。

pip install reversejp
# 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)

出力結果:

130010 東京都 Tokyo
1310100 千代田区 Chiyoda City
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?