Skip to content

nkosaku/pyja_geocoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyja geocoder

pyja geocoder is a Python package for reverse geocoding in Japan. It uses vectorized operations with GeoPandas to efficiently map latitude and longitude coordinates to corresponding Japanese city attributes, based on official shapefile data provided by MLIT (Ministry of Land, Infrastructure, Transport, and Tourism).

Features

  • Batch Processing: Reverse geocode multiple coordinates simultaneously using a DataFrame.
  • Single Point Geocoding: Reverse geocode a single latitude/longitude coordinate.
  • Efficient Spatial Operations: Leverages GeoPandas and spatial indexing for fast lookups.

Installation

Install from PyPI

pip install pyja-geocoder

Install from Source

  1. Clone the repository:

    git clone https://github.com/yourusername/pyja_geocoder.git
    cd pyja_geocoder
  2. Install the package:

    pip install .

Usage

Import the Package

from pyja_geocoder import reverse_geocode_from_df, reverse_geocode_from_points, reverse_geocode_single

Reverse Geocode a Single Point

lat, lon = 35.6895, 139.6917  # Latitude and longitude for Tokyo
city, citycode = reverse_geocode_single(lat, lon)
print("City:", city)
print("City Code:", citycode)

Reverse Geocode a List of Points

points = [(35.6895, 139.6917), (34.6937, 135.5022)]  # Tokyo and Osaka
result_df = reverse_geocode_from_points(points)
print(result_df)

Reverse Geocode a DataFrame of Points

import pandas as pd

df = pd.DataFrame({"latitude": [35.6895, 34.6937], "longitude": [139.6917, 135.5022]})
result_df = reverse_geocode_from_df(df)
print(result_df)

Load the Default Shapefile

The package uses the official MLIT shapefile for geocoding. The data will be downloaded and cached automatically if not already present.

from pyja_geocoder import load_japan_shapefile

gdf = load_japan_shapefile()  # Load the MLIT shapefile as a GeoDataFrame

Data Source

The shapefile used by this package is sourced from MLIT (Ministry of Land, Infrastructure, Transport, and Tourism). The latest data can be accessed here.

About

Python package for reverse geocoding in Japan

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages