npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

japan-address-search

v2.1.1

Published

オープンデータを使用した日本の住所検索モジュール。現在の住所と明治時代以前の地名を文字列と緯度経度で検索可能。

Downloads

92

Readme

japan-address-search

test

日本の住所を文字列と緯度経度で検索できるNode.jsモジュールです。 現在の住所データ以外に古い地名(明治時代以前の地名)の検索にも対応しています。

このモジュールでは以下のことができます。

  • 現在の住所データ
    • 表記の正規化
    • 部分一致検索
    • 逆ジオコーディング検索(緯度経度による検索)
  • 古い地名データ
    • 部分一致検索
    • 逆ジオコーディング検索(緯度経度による検索)

モジュール内に含まれるデータベースを対象に検索が行われます。 大量の検索・正規化したい住所がある場合、外部Webサービスを使用しないため、 高速に大量のデータを検索できます。

インストール

コード内で使用する場合は以下のようにインストールしてください。

$ npm install japan-address-search

コマンドラインインタフェースで使用する場合は、-gをつけてグローバル環境にインストールしてください。

$ npm install -g japan-address-search

使い方

node.js モジュールとしてインストールすると以下のようにコード上から実行できます。

現在の住所データの正規化・部分一致検索(デフォルト10件)

const convert = require('japan-address-search');
convert("霞が関2").then(json=>{
  console.log(json);
});

現在の住所データの逆ジオコーディング検索(デフォルト10件)

const convert = require('japan-address-search');
const point = {
  lat: 35.675551,
  lng: 139.750413
}
convert(point).then(json=>{
  console.log(json);
});

古い地名データの部分一致検索(デフォルト10件)

const convert = require('japan-address-search');
convert("神保町", {type: "old"}).then(json=>{
  console.log(json);
});

古い地名データの逆ジオコーディング検索(デフォルト10件)

const convert = require('japan-address-search');
const point = {
  lat: 35.675551,
  lng: 139.750413
}
convert(point, {type: "old"}).then(json=>{
  console.log(json);
});

検索件数の上限を変更したい場合は、以下のように指定してください。

// 検索件数を5件に変更
convert(point, {type: "old", limit: 5}).then(json=>{
  console.log(json);
});

コマンドラインインターフェースでは以下のように利用できます。

# 現在の住所データの正規化・部分一致検索
$ japan-address-search -s 神保町 > output.json

# 現在の住所データの逆ジオコーディング検索
$ japan-address-search --lat 35.675551 --lng 139.750413 > output.json

# 古い地名データの部分一致検索
$ japan-address-search -s 神保町 --old > output.json

# 古い地名データの逆ジオコーディング検索
$ japan-address-search --lat 35.675551 --lng 139.750413 --old > output.json

# 検索件数の上限を変更
$ japan-address-search -s 神保町 --limit 5 > output.json

出力例

検索結果は以下のようなJSONデータとして出力されます。

検索された住所が現在の住所データか古い地名データかは住所オブジェクト内の種別の値で判別できます。

種類 | 種別の値 --- | --- 現在の住所 | 位置参照情報 古い地名 | 歴史地名データ

現在の住所データの検索結果

{
  "@context": "https://imi.go.jp/ns/core/context.jsonld",
  "場所": [
    {
      "@type": "場所型",
      "住所": [
        {
          "@type": "住所型",
          "表記": "霞が関2",
          "都道府県": "東京都",
          "都道府県コード": "http://data.e-stat.go.jp/lod/sac/C13000",
          "市区町村": "千代田区",
          "市区町村コード": "http://data.e-stat.go.jp/lod/sac/C13101",
          "町名": "霞が関",
          "丁目": "2",
          "種別": "位置参照情報"
        }
      ],
      "地理座標": {
        "@type": "座標型",
        "緯度": "35.675551",
        "経度": "139.750413"
      }
    }
  ]
}

古い地名データの検索結果

{
  "@context": "https://imi.go.jp/ns/core/context.jsonld",
  "場所": [
    {
      "@type": "場所型",
      "住所": [
        {
          "@type": "住所型",
          "種別": "歴史地名データ",
          "ID": "10025110",
          "町名": "神保町",
          "説明": "「大日本地名辞書」6巻 352頁",
          "都道府県": "武蔵",
          "都道府県コード": "594",
          "市区町村": "神田区",
          "市区町村コード": "917"
        },
        {
          "@type": "住所型",
          "表記": "東京都千代田区神田神保町二丁目",
          "都道府県": "東京都",
          "都道府県コード": "http://data.e-stat.go.jp/lod/sac/C13000",
          "市区町村": "千代田区",
          "市区町村コード": "http://data.e-stat.go.jp/lod/sac/C13101",
          "町名": "神田神保町",
          "丁目": "2",
          "種別": "位置参照情報"
        }
      ],
      "地理座標": [
        {
          "@type": "座標型",
          "緯度": "35.695555",
          "経度": "139.757500"
        }
      ]
    },
    ...
  ]
}

使用しているデータについて

japan-address-searchで使用してる現在の住所データと古い地名データとして、以下で公開されているオープンデータを使用しています。

データ | データソース | バージョン | ライセンス --- | --- | --- | --- 現在の住所データ | 国土地理院 位置参照情報 | 令和元年度版 | 利用規約 現在の住所データ | 統計LOD | 2020/10/06取得 | CC BY 4.0 古い地名データ | 歴史地名データ | 2020/09/07取得 | 利用規約

謝辞

japan-address-search は経済産業省が公開するimi-enrichment-address(住所変換コンポーネント)を元に作成しました。 経済産業省、並びに、上記データを公開されている国土地理院、総務省統計局、人間文化研究機構、H-GIS研究会には深く感謝いたします。