Metadata-Version: 2.4
Name: gridpin
Version: 0.11.0
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Dist: geopy>=2.0 ; extra == 'geopy'
Requires-Dist: pandas>=1.5 ; extra == 'pandas'
Provides-Extra: geopy
Provides-Extra: pandas
License-File: LICENSE
License-File: THIRDPARTY.yml
Summary: Offline forward and reverse geocoder: country files, no server or database import, no per-request fees; queries stay local
Keywords: geocoding,geocoder,offline,reverse-geocoding,gis,overture,openstreetmap
Home-Page: https://gridpin.dev
License: Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Benchmark, https://gridpin.dev/bench
Project-URL: Documentation, https://gridpin.dev/docs
Project-URL: Homepage, https://gridpin.dev
Project-URL: Issues, https://github.com/gridpin/gridpin/issues
Project-URL: Repository, https://github.com/gridpin/gridpin

# GridPin

[![PyPI](https://img.shields.io/pypi/v/gridpin)](https://pypi.org/project/gridpin/)
[![crates.io](https://img.shields.io/crates/v/gridpin)](https://crates.io/crates/gridpin)
[![DuckDB community extension](https://img.shields.io/badge/DuckDB-community%20extension-fff000)](https://duckdb.org/community_extensions/extensions/gridpin_ext)
[![MCP server](https://img.shields.io/badge/MCP-server-blue)](https://gridpin.dev/mcp-geocoding)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/gridpin/gridpin/blob/main/LICENSE)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.23610378.svg)](https://doi.org/10.5281/zenodo.23610378)
[![CI](https://github.com/gridpin/gridpin/actions/workflows/ci.yml/badge.svg)](https://github.com/gridpin/gridpin/actions/workflows/ci.yml)
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/gridpin/gridpin/blob/main/examples/colab_quickstart.ipynb)
[![Live demo](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://gridpin.streamlit.app)

Offline forward and reverse geocoding from a memory-mapped country file.
*Off the grid. On the grid.*

GridPin is an offline geocoder for Python, the command line, SQL and AI agents: it turns
street addresses into coordinates and coordinates into street-level addresses.
No API key, no server, no database import, no per-request fees, and every geocoding query
stays on your machine. After you install the package and download a sheet,
GridPin makes no network requests.

```bash
pip install --upgrade gridpin
```

The wheel contains the engine, not the data: **download a country sheet
separately**. Free static sheets for Australia, Belgium, Brazil, Canada, France, Germany, Italy, Mexico, the Netherlands, New Zealand, Poland, Serbia, Spain and the United States
are listed at <https://gridpin.dev/docs#delivery> — no account, no key, no
sign-up.

One command does the download and the check: `pip install gridpin-mcp`, then
`gridpin-fetch fr` puts the France sheet in `~/.cache/gridpin` and verifies it against the
signed release; from Python, `gridpin_mcp.sheets.download("fr")` returns the same path. The
same package is an MCP server for AI agents (`uvx gridpin-mcp`).

With pandas: `pip install "gridpin[pandas]"`, then `gridpin.sheets.fetch("us")`,
`gridpin.geocode_df(df, "address", "us")` (or `df.gridpin.geocode(...)`) and `gridpin.reverse_df(df, "us")`; the
`gp_*` columns are the same as in `gridpin batch` CSV and `gp_geocode_df` in R. `gridpin.sheets.list / path / verify /
fetch` use the same cache and checks as `gridpin sheets`. Extras `[pandas]`, `[geopy]`; without them the wheel still has
no dependencies.

Each country is one sheet. Limits of the sheets: **Germany's Bavaria and New Zealand have no postcodes**; the
United States has point addresses in 35 states and Census address ranges elsewhere. Client update required: use
0.10.0 or newer, because older engines have no rules for Poland and New Zealand.

```python
import gridpin

g = gridpin.Geocoder("france.bin")
g.geocode("8 Boulevard du Port, Amiens", 1)
g.reverse(49.8945, 2.2949, 1)

# optional POI layer (cascade built in: address index first,
# POI only on weak results, exact addresses never overridden)
g = gridpin.Geocoder("france.bin", poi="fr_poi.bin")
```

## Common tasks

- **Geocode a CSV of addresses without an API key.** `gridpin batch usa.bin addresses.csv geocoded.csv` adds the
  `gp_*` columns to every row; in Python, `geocode_many()` spreads a list across all cores.
  Guide: <https://gridpin.dev/geocode-csv>
- **A self-hosted alternative to Nominatim that is easy to set up.** There is no database import: `gridpin serve usa.bin`
  answers `/search?q=...&format=json` in the Nominatim format, and the Photon and Google Geocoding API formats, from one
  file, so an existing client changes only its base URL.
  Guides: <https://gridpin.dev/nominatim-alternative>, <https://gridpin.dev/geocoding-server>
- **Geocode addresses inside DuckDB.** `INSTALL gridpin_ext FROM community;` then `gridpin_geocode(address)` in SQL
  (DuckDB 1.5.6 or newer; older DuckDB versions install an older build).
  Guide: <https://gridpin.dev/duckdb-geocoding>
- **Offline reverse geocoding at street level.** `g.reverse(lat, lon, 1)` returns the nearest indexed address with
  `distance_m`. Guide: <https://gridpin.dev/reverse-geocoding>
- **Geocoding for AI agents with no API key.** `uvx gridpin-mcp` is an MCP server for offline geocoding.
  Guide: <https://gridpin.dev/mcp-geocoding>
- **A geocoder built on Overture Maps data.** Overture Maps publishes addresses from national registries; GridPin turns
  each country's addresses into one file. Guide: <https://gridpin.dev/overture-geocoder>

The engine is written in Rust (the `gridpin` crate on crates.io) and reads one memory-mapped file per country.

Country guides: [Australia](https://gridpin.dev/geocoding-australia), [Belgium](https://gridpin.dev/geocoding-belgium), [Brazil](https://gridpin.dev/geocoding-brazil), [Canada](https://gridpin.dev/geocoding-canada), [France](https://gridpin.dev/geocoding-france), [Germany](https://gridpin.dev/geocoding-germany), [Italy](https://gridpin.dev/geocoding-italy), [Mexico](https://gridpin.dev/geocoding-mexico), [the Netherlands](https://gridpin.dev/geocoding-netherlands), [New Zealand](https://gridpin.dev/geocoding-new-zealand), [Poland](https://gridpin.dev/geocoding-poland), [Serbia](https://gridpin.dev/geocoding-serbia), [Spain](https://gridpin.dev/geocoding-spain) and [the United States](https://gridpin.dev/geocoding-usa).

If GridPin is useful to you, [a star on GitHub](https://github.com/gridpin/gridpin) helps other people find it.

Three limits worth knowing before you build on this:

- **Reverse** returns the nearest *indexed* address — or a street-centroid
  approximation — together with `distance_m`. It is not a rooftop fix.
- **Speed:** exact lookups run at ~3,000/s, measured on the France sheet and a
  single arm64 laptop core. Typo-tolerant fuzzy matching is much slower (tens of
  ms/query) — use `geocode_many()` to batch.
- **Places layers** (`<cc>_poi.bin`, one per country) are opt-in. Address lookup is the core product;
  the places layer is younger and never overrides an exact address match.

- Country files & docs: <https://gridpin.dev/docs>
- Quality benchmark, including where other geocoders score higher:
  <https://gridpin.dev/bench>
- Source: <https://github.com/gridpin/gridpin>
- Issues: <https://github.com/gridpin/gridpin/issues>
- Engine license: Apache-2.0. Data files carry their own source licenses —
  see <https://github.com/gridpin/gridpin/blob/main/ATTRIBUTIONS.md>

