@digital-go-jp/abr-geocoder v2.0.0
abr-geocoder (Digital Agency Address Base Registry Geocoder)
Description
A geocoder that matches input address strings with the Address Base Registry maintained by the Digital Agency, Government of Japan, outputting normalized address strings, town IDs, latitude and longitude, etc. It analyzes Japanese domestic address notation, absorbs variations, and outputs normalized results according to the hierarchy.
Features
- Geocoder targeting domestic addresses in Japan.
- Normalizes address notation according to the Address Base Registry and hierarchy.
- Supports
residence indication
andpartial number (lot number)
. - Uses SQLite, enabling geocoding within the server.
- High-speed processing through multithreading.
- Supports six output formats:
csv
,json
,geojson
,ndjson
,ndgeojson
,simplified
.
Use Cases
- Usable as a command:
- Pipeline with standard input/output.
- Input/output via file.
- Usable as a REST server.
- Usable as a Node.js library:
- Supports individual requests and streams.
Limitations
- Cannot search by landmarks (e.g., famous facility names).
- Cannot search by postal codes.
- Cannot search by alphabet (English notation).
- Limited support for searches by Kyoto street names.
- Cannot search by incomplete address notation.
Installation
Global installation
npm install -g @digital-go-jp/abr-geocoder abrg # Verify it runs
Local install
npm install @digital-go-jp/abr-geocoder npm link abrg # Verify it runs
abrg download
command
Downloads the necessary dataset for geocoding from the Address Base Registry and builds the database using SQLite.
abrg download [options]
You can specify a particular prefecture or municipality to build a localized database, reducing the data size and speeding up database construction.
Use the National Local Government Codes to specify the region(s). Separate multiple regions with spaces.
# Download data for Tokyo abrg download -c 130001 # Download data for Tokyo and Kanagawa abrg download -c 130001 140007 # Download data for Chiyoda ward abrg download -c 131016
You can change the directory to download the dataset files and save the database. The default is
$HOME/.abr-geocoder
.abrg download -d (path to directory to save data)
abrg download --silent
abrg download --debug
abrg update-check
command
Checks for data updates. If there is local data, it checks for updates in the municipalities contained in the database. If new data is available, it can be downloaded.
abrg update-check [options]
# Continue downloading abrg update-check --yes # Do not continue downloading abrg update-check --no
abrg update-check --silent
Specifies the directory to save the database. The default is
$HOME/.abr-geocoder
.abrg update-check -d (path to directory to save data)
abrg update-check --debug
abrg
command
Geocodes the input address string with the database and outputs normalized address strings, town IDs, latitude, longitude, etc.
$ abrg <inputFile> [<outputFile>] [options]
<inputFile>
Specifies how to input data into the command.
Example:
abrg ./sample.txt
sample.txt:
東京都千代田区紀尾井町1-3 // 1-3 Kioicho, Chiyoda-ku, Tokyo 東京都千代田区永田町1-10-1 // 1-10-1 Nagatacho, Chiyoda-ku, Tokyo ... 東京都千代田区永田町一丁目7番1号 // 1-7-1 Nagatacho, Chiyoda-ku, Tokyo
Example:
echo "東京都千代田区紀尾井町1-3 東京ガーデンテラス紀尾井町 19階、20階" | abrg -
<outputFile>
Specifies where to output the processing results. If omitted, outputs to standard output (stdout).
Example:
abrg ./input.txt ./output.json
Example:
cat ./sample.txt | abrg - | jq
You can change the output format with the
-f
,--format
option. The default isjson
.format Description csv Outputs results in comma-separated csv format simplified Outputs results in comma-separated csv format with limited fields json Outputs results in JSON format ndjson Outputs results in NDJSON format geojson Outputs results in GeoJSON format ndgeojson Outputs results in NDGeoJSON format Example:
echo "東京都町●市森野2-2-22" | abrg - --fuzzy "●"
abrg ./input.txt ./output.txt --silent
Specifies the directory to save the database. The default is
$HOME/.abr-geocoder
.abrg ./input.txt ./output.txt -d (path to directory to save data)
abrg ./input.txt ./output.txt --debug
abrg serve
command
Starts the geocoder as a REST API server.
abrg serve [options]
Changes the port number for the REST API server. The default is
3000
.abrg serve -p 8080
Specifies the directory to save the database. The default is
$HOME/.abr-geocoder
.abrg serve -d (path to directory to save data)