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).
- 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.
pip install pyja-geocoder-
Clone the repository:
git clone https://github.com/yourusername/pyja_geocoder.git cd pyja_geocoder -
Install the package:
pip install .
from pyja_geocoder import reverse_geocode_from_df, reverse_geocode_from_points, reverse_geocode_singlelat, lon = 35.6895, 139.6917 # Latitude and longitude for Tokyo
city, citycode = reverse_geocode_single(lat, lon)
print("City:", city)
print("City Code:", citycode)points = [(35.6895, 139.6917), (34.6937, 135.5022)] # Tokyo and Osaka
result_df = reverse_geocode_from_points(points)
print(result_df)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)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 GeoDataFrameThe shapefile used by this package is sourced from MLIT (Ministry of Land, Infrastructure, Transport, and Tourism). The latest data can be accessed here.