duva 🕊️
Reverse geocode Swedish coordinates to RegSO areas.
Install
pip install duva
What you get
locate(x=17.88, y=59.35)
{
"regsokod": "0180R009",
"regsonamn": "Blackeberg",
"kommunkod": "0180",
"kommunnamn": "Stockholm",
"lanskod": "01",
"lansnamn": "Stockholms län",
"not_on_land": false,
"offshore": false
}
Usage
from duva import locate, locate_many, enrich_df, from_code, from_name, search
# Single coordinate (WGS84) — returns a dict
locate(x=17.88, y=59.35)
# As RegSO object
result = locate(x=17.88, y=59.35, as_object=True)
result.regsonamn # 'Blackeberg'
# List of coordinates
locate_many([(17.88, 59.35), (18.07, 59.28)])
# Enrich a Polars DataFrame
enrich_df(df, x_col="lon", y_col="lat")
# Lookup by RegSO code
from_code("0180R009")
# Lookup by name (returns list since names are not unique across Sweden)
from_name("Blackeberg")
from_name("Östermalm") # returns all areas named Östermalm across Sweden
# Search by partial name with optional kommun/län filters
search("östermalm")
search("centrum", kommunnamn="Sollentuna", lansnamn="Stockholms län")
RegSO object
| Field | Type | Example | Description |
|---|---|---|---|
regsokod |
str |
0180R009 |
SCB area code |
regsonamn |
str |
Blackeberg |
Area name |
kommunkod |
str |
0180 |
Municipality code |
kommunnamn |
str |
Stockholm |
Municipality name |
lanskod |
str |
01 |
County code |
lansnamn |
str |
Stockholms län |
County name |
not_on_land |
bool |
False |
True if coordinate is over water |
offshore |
bool |
False |
True if outside any municipality boundary (international water) |
objektidentitet |
str |
141f6a1d-... |
SCB internal UUID |
objekttyp |
str |
regso |
Always regso |
version |
str |
2025_v2 |
Dataset version |
referensdatum |
str |
20250101 |
Dataset reference date |
not_on_land is True when the coordinate falls over water. offshore is True specifically for international water where no municipality boundary exists — a coordinate over a lake will have not_on_land=True but offshore=False.
Notes
- Input coordinates must be WGS84 (standard GPS)
- The scope of this library is to facilitate coordinate lookup inside Sweden, hence any coordinate outside its borders will raise
ValueErrorfor better debugging - Area names are not unique across Sweden —
from_nameandsearchreturn lists - The source of truth for spatial polygons this library relies on is given by SCB's RegSO 2025 and municipality boundaries. For further reading please visit: SCB RegSO documentation
Metadata
Release files for duva 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| duva-0.3.5.tar.gz | 19.4 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| duva-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.7 MB
Release files / duva-0.3.5.tar.gz
| Download URL | duva-0.3.5.tar.gz |
|---|---|
| Size | 19.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af1ac66318b08f3ebf10e54b0ec77c8962a98c32a924a63e4dde9f06600fe4e0
|
|
BLAKE2b-256 checksum How to use checksums |
569138a6deab9a69085b504f65c95fe79f3ee31a11937d7ff4c4932427ee03b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 12, 2026.
Transparency logRelease files / duva-0.3.5-py3-none-any.whl
| Download URL | duva-0.3.5-py3-none-any.whl |
|---|---|
| Size | 19.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb0948868812c2fc3b10ebdefbc0ec911456e920cb08f174b8b5b1af194013eb
|
|
BLAKE2b-256 checksum How to use checksums |
ceb5668890519bbeed3308aa2df15728c94b4e18baa4ae2c2837f76e356f994c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 12, 2026.
Transparency logSecurity for duva 0.3.5
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for duva-0.3.5.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 Jun 12, 2026.
Transparency logA 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.