Skip to main content

GeoFinder Logo GeoFinder-ICGC

Geocoder for Catalonia using the ICGC service (Institut Cartogràfic i Geològic de Catalunya). Dual API: Native async + sync wrappers for simple scripts.

Python 3.10+ License: GPL-2.0


GeoFinder-ICGC is an advanced geocoder for Catalonia designed to be robust, fast, and easy to use.

Installation

# Basic installation
pip install geofinder-icgc

# With coordinate transformation support (recommended)
pip install geofinder-icgc[pyproj]

Since 3.0.0 this package is the library only. The MCP server for AI assistants lives in a separate repository built on mcp-secure-core and uses this library as a dependency; until it is released, pin geofinder-icgc<3 if you need the server that was bundled up to 2.4.2.

Quick Start

Synchronous Usage (Simple scripts)

from geofinder import GeoFinder

gf = GeoFinder()
results = gf.find_sync("Barcelona")

for r in results:
    print(f"{r.nom} ({r.nomTipus}) - {r.x}, {r.y}")

Asynchronous Usage (High performance)

import asyncio
from geofinder import GeoFinder

async def main():
    async with GeoFinder() as gf:
        results = await gf.find("Diagonal 100, Barcelona")
        print(f"Found: {len(results)}")

asyncio.run(main())

Features Guide

1. General Search (find / find_sync)

Automatically detects the search type based on input:

  • Toponyms: "Montserrat", "Girona"
  • Addresses: "Carrer Aragó 50, Barcelona", "Gran Via 123"
  • Coordinates: "430000 4580000 EPSG:25831", "2.17 41.38 EPSG:4326"
  • Roads: "C-32 km 10"
  • Rectangles: "X1 Y1 X2 Y2"

Toponym results come municipality first, then other topo1 places, topo2 places and any other layer, so find("Barcelona")[0] is the city. size is a maximum (None or <= 0 means default_size); coordinate and rectangle searches add their own Coordenada/Rectangle entry on top of the size results from the ICGC. With space-separated numbers a comma is a decimal separator ("430000,5 4580000,5" is a point), unless the text already uses . for decimals or a comma has more digits after it than before; in those cases, and without spaces, it separates numbers ("430000,4580000", "1,2,3,4", "430000,4580000 431000,4581000", "2.1,41.3 2.2,41.4"). An empty or blank text returns [] without calling the service.

2. Reverse Geocoding (find_reverse / find_reverse_sync)

Find places or addresses from coordinates.

# Supports EPSG:25831 (default) and EPSG:4326 (GPS)
results = await gf.find_reverse(430000, 4580000)

3. Autocomplete (autocomplete / autocomplete_sync)

Ideal for implementing real-time search suggestions.

suggestions = await gf.autocomplete("Barcel")

4. Proximity Search (search_nearby)

Find places within a given radius around a reference point.

# Search everything within 2km of Sagrada Família
nearby = await gf.search_nearby("Sagrada Família, Barcelona", radius_km=2.0)

5. Batch Processing (find_batch / find_reverse_batch)

Execute multiple queries in parallel with optimized concurrency.

queries = ["Barcelona", "Girona", "Lleida", "Tarragona"]
batch_results = await gf.find_batch(queries, max_concurrency=10)

6. Response with Metadata (find_response)

Returns a GeoResponse object that includes results and performance metadata such as execution time.

7. Query Classification (parse_query)

Find out how a text will be searched before running the search. find() uses this same parser, so the answer always matches what find() does.

from geofinder import parse_query

q = parse_query("C-32 km 10")
q.kind, q.road, q.km                     # ('road', 'C-32', '10')
parse_query("430000 4580000").epsg       # 25831 (default_epsg), epsg_explicit=False
parse_query("Barcelona, Diagonal 100")   # AddressQuery(municipality='Barcelona', ...)

kind is one of rectangle, coordinate, road, address or placename; each kind is its own frozen model (RectangleQuery, CoordinateQuery, RoadQuery, AddressQuery, PlacenameQuery).

Configuration

The GeoFinder constructor allows customizing the library behavior:

Parameter Type Description
timeout int Maximum wait time (default: 5s).
cache_size int LRU cache capacity (default: 128).
cache_ttl int Cache time-to-live in seconds (default: 3600).
max_retries int Number of retries on failure (default: 3).
verify_ssl bool Verify SSL certificates (default: True).
http_client httpx.AsyncClient Share your own httpx client (not closed by GeoFinder).
transport HTTPTransport Send every request through your own transport (see below). Not combinable with http_client.
total_timeout float Time budget in seconds for each public call, all requests and retries included (default: none).

Custom HTTP transport

GeoFinder never needs to talk to httpx directly: every request is a GET to a full URL sent through an HTTPTransport. The default is HttpxTransport. To use your own network client (for example one with an egress allow-list), write a small adapter and inject it:

from geofinder import (
    GeoFinder, ServiceConnectionError, ServiceHTTPError, ServiceTimeoutError, TransportResponse,
)

class MyTransport:
    def __init__(self, http):
        self._http = http

    async def get(self, url: str, *, timeout: float) -> TransportResponse:
        try:
            body = await self._http.fetch_text(url, timeout=timeout)
        except MyTimeout as e:
            raise ServiceTimeoutError(str(e), url=url) from e       # retried
        except MyNetworkError as e:
            raise ServiceConnectionError(str(e), url=url) from e    # retried
        except MyStatusError as e:
            raise ServiceHTTPError(str(e), url=url, status_code=e.status) from e  # 5xx retried
        return TransportResponse(200, body, url)

gf = GeoFinder(transport=MyTransport(client), total_timeout=8, max_retries=1)

The library still builds the URL, checks the status code, parses the JSON, validates the response and retries. Any other exception raised by the transport is not retried and reaches you as a ServiceError. GeoFinder never closes an injected transport.

Note: most async HTTP clients (httpx included) are bound to the event loop they first ran in. Each *_sync call runs its own loop, so a client you inject through http_client= or a transport should be used from async code (await gf.find(...)), not shared across several *_sync calls.

total_timeout covers the whole public call: search_nearby, which chains several requests, or a coordinate search, which runs two in parallel, share a single budget. In batches, queries that do not finish in time fail like any other query error and the rest keep their results.


Documentation


Resources


License

Distributed under the GPL-2.0-or-later license. Based on the original ICGC work adapted for standalone use.


© 2025 ICGC / Adapted by Goalnefesh

Small changes are powerful

Metadata

Release files for geofinder-icgc 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geofinder-icgc 3.0.0
File Size Uploaded Provenance Actions
geofinder_icgc-3.0.0.tar.gz 44.8 kB With provenance Details for geofinder_icgc-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geofinder-icgc 3.0.0
File Interpreter ABI Platform Actions
geofinder_icgc-3.0.0-py3-none-any.whl Python 3 none any Details for geofinder_icgc-3.0.0-py3-none-any.whl

Total release size: 89.9 kB

Release files / geofinder_icgc-3.0.0.tar.gz

Download URL geofinder_icgc-3.0.0.tar.gz
Size 44.8 kB
Tags Source
SHA-256 checksum
How to use checksums
192e88bf5723c442fc35abb3dca05df77ef76caff8c28fe44f2c3448069477fb
BLAKE2b-256 checksum
How to use checksums
d8dc7612a51077d4b11bfb8cb686e52e09d01073ea7924791298d5d0c13ac3f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / geofinder_icgc-3.0.0-py3-none-any.whl

Download URL geofinder_icgc-3.0.0-py3-none-any.whl
Size 45.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bb1ffee8d69c731e6fcb94ffa63b7d1dc5065b7fe7a858fa6f7ccdb36f5a654
BLAKE2b-256 checksum
How to use checksums
75fb6305fcfbe29be99ab08b4ff1b9c3acc598a0372cffe5104e722200d98d3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for geofinder-icgc 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geofinder_icgc-3.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page