SkillAgentSearch skills...

Iceaddr

Python package to look up information about Icelandic street addresses, postcodes and placenames. Icelandic geocoding.

Install / Use

/learn @sveinbjornt/Iceaddr

README

License Python 3.9 Release PyPI Build

iceaddr

<img src="https://raw.githubusercontent.com/sveinbjornt/iceaddr/refs/heads/master/iceaddr_logo.svg" width="192" height="192" align="right" style="float: right; margin-left: 30px;" alt="iceaddr logo">

Look up Icelandic street addresses, postcodes and placenames

iceaddr is a pure Python >= 3.9 package to look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. The underlying data is contained in a local SQLite database assembled from the following sources:

Since no networking takes place, lookups are very fast and can be performed offline. The package is useful for geocoding and reverse geocoding of Icelandic addresses and placenames, as well as validating addresses and postcodes. No external dependencies are required.

Installation

The latest version of iceaddr is available via PyPI.

pip install iceaddr

Examples

Look up address with postcode

>>> from iceaddr import iceaddr_lookup
>>> a = iceaddr_lookup('Austurstræti', number=14, postcode=101)
>>> pprint(a)
[{'bokst': '',
  'byggd': 1,
  'heiti_nf': 'Austurstræti',
  'heiti_tgf': 'Austurstræti',
  'hnitnum': 10083839,
  'husnr': 14,
  'landnr': 100852,
  'lat_wgs84': 64.147529217656,
  'long_wgs84': -21.9389394651385,
  'postnr': 101,
  'serheiti': '',
  'stadur_nf': 'Reykjavík',
  'stadur_tgf': 'Reykjavík',
  'svaedi_nf': 'Höfuðborgarsvæðið',
  'svaedi_tgf': 'Höfuðborgarsvæðinu',
  'svfheiti': 'Reykjavíkurborg',
  'svfnr': 0,
  'tegund': 'Þéttbýli',
  'vidsk': ''}]

Look up address with placename

>>> from iceaddr import iceaddr_lookup
>>> a = iceaddr_lookup('Öldugötu', 4, 'Reykjavík')
>>> pprint(a)
[{'bokst': '',
  'byggd': 1,
  'heiti_nf': 'Öldugata',
  'heiti_tgf': 'Öldugötu',
  'hnitnum': 10017023,
  'husnr': 4,
  'landnr': 100570,
  'lat_wgs84': 64.1484874806941,
  'long_wgs84': -21.9452072913341,
  'postnr': 101,
  'serheiti': '',
  'stadur_nf': 'Reykjavík',
  'stadur_tgf': 'Reykjavík',
  'svaedi_nf': 'Höfuðborgarsvæðið',
  'svaedi_tgf': 'Höfuðborgarsvæðinu',
  'svfheiti': 'Reykjavíkurborg',
  'svfnr': 0,
  'tegund': 'Þéttbýli',
  'vidsk': ''}]

Street and place names can be provided in either nominative (nf.) or dative (þgf.) case (e.g. both 'Öldugata' and 'Öldugötu' will work, as will both 'Selfoss' and 'Selfossi').

Please note that iceaddr_lookup() returns a list of zero or more addresses matching the criterion.

>>> from iceaddr import iceaddr_lookup
>>> iceaddr_lookup('Dúfnahólar', 10)
[]
>>> res = iceaddr_lookup('Öldugata', 9)
>>> [(a['postnr'], a['stadur_nf']) for a in res]
[(101, 'Reykjavík'), (220, 'Hafnarfjörður'), (621, 'Dalvík')]

For natural search string queries, the module provides iceaddr_suggest():

>>> from iceaddr import iceaddr_suggest
>>> a = iceaddr_suggest('Öldugata 4, Rey')
>>> [n['stadur_tgf'] for n in a]
['Reykjavík', 'Reyðarfirði']
>>> a = iceaddr_suggest('Öldugö', limit=200)
>>> len(a)
151

The default limit on results from both functions is 50.

Find closest address

Given a set of WGS84 coordinates, the nearest_addr() function returns a list of the nearest addresses in the database:

>>> from iceaddr import nearest_addr
>>> addr = nearest_addr(64.148446, -21.944933)[0]
>>> print(f"{addr['heiti_nf']} {addr['husnr']}")
Öldugata 4

Address Keys

| Key | Value description | | ------------- |---------------------------------------------------------| | bokst | House letter, e.g. "A", "b" | | byggd | Byggðarnúmer in municipality | | heiti_nf | Street name (nominative case, nf.), e.g. 'Öldugata' | | heiti_tgf | Street name (dative case, þgf.), e.g. 'Öldugötu' | | hnitnum | Hnitnúmer staðfangahnits | | husnr | House number | | landnr | Hlaupandi sex stafa auðkennisnúmer í landeignaskrá HMS | | lat_wgs84 | Latitude (WGS84 coordinates) | | long_wgs84 | Longitude (WGS84 coordinates) | | postnr | Postcode (e.g. 101) | | serheiti | Special name | | stadur_nf | Placename (nominative case), e.g. 'Selfoss' | | stadur_tgf | Placename (dative case), e.g. 'Selfossi' | | svaedi_nf | Region (nominative case), e.g. 'Höfuðborgarsvæðið' | | svaedi_tgf | Region (dative case), e.g. 'Höfuðborgarsvæðinu' | | svfheiti | Municipality name (e.g. 'Borgarbyggð') | | svfnr | Municipality code (e.g. 3609) | | tegund | Type (either 'Þéttbýli' (urban) or 'Dreifbýli' (rural)) | | vidsk | Additional information |

Postcodes

Info about a given postcode

>>> from iceaddr import postcode_lookup
>>> postcode_lookup(400)
{   "svaedi_nf": "Vesturland og Vestfirðir",
    "svaedi_tgf": "Vesturlandi og Vestfjörðum",
    "stadur_nf": "Ísafjörður",
    "stadur_tgf": "Ísafirði",
    "tegund": "Þéttbýli"}
# Accepts string or int
>>> postcode_lookup("107")
{   "svaedi_nf": "Höfuðborgarsvæðið",
    "svaedi_tgf": "Höfuðborgarsvæðinu",
    "stadur_nf": "Reykjavík",
    "stadur_tgf": "Reykjavík",
    "tegund": "Þéttbýli",
    "lysing": "Vesturbær"}
>>> from iceaddr import POSTCODES
>>> pprint(POSTCODES[101])
{   "svaedi_nf": "Höfuðborgarsvæðið",
    "svaedi_tgf": "Höfuðborgarsvæðinu",
    "stadur_nf": "Reykjavík",
    "stadur_tgf": "Reykjavík",
    "tegund": "Þéttbýli",
    "lysing": "Miðborg"}

Get postcodes for a placename ("örnefni")

>>> from iceaddr import postcodes_for_placename
>>> postcodes_for_placename('Ísafjörður')
[400, 401]
>>> postcodes_for_placename('Kópavogi')
[200, 201, 202, 203]
>>> postcodes_for_placename('kópav', partial=True)
[200, 201, 202, 203]

Get postcodes for a region ("svæði")

>>> from iceaddr import postcodes_for_region
>>> postcodes_for_region('Norðurland')
[530, 531, 540, 541, 545, ...]
>>> postcodes_for_region('Höfuðborgarsvæðið')
[101, 102, 103, 104, 105, ...]

Placenames ("örnefni")

>>> from iceaddr import placename_lookup
>>> placename_lookup('Meðalfellsvatn')
[{'flokkur': 'Vatnaörnefni Mið',
  'id': 2339,
  'lat_wgs84': 64.3112049,
  'long_wgs84': -21.5997926,
  'nafn': 'Meðalfellsvatn'}]

If more than one placename match is found, the results are ordered by size, with precedence given to municipalities and densely populated areas.

>>> placename_lookup("Egilsstað", partial=True)
[{'flokkur': 'Þéttbýli',
  'id': 63208,
  'lat_wgs84': 65.2637152,
  'long_wgs84': -14.3931143,
  'nafn': 'Egilsstaðir'},
 {'flokkur': 'Landörnefni Lítið',
  'id': 108285,
  'lat_wgs84': 65.3516154,
  'long_wgs84': -20.610947,
  'nafn': 'Egilsstaðir'}]

Find closest placenames ("örnefni")

Given a set of WGS84 coordinates, the nearest_placenames() function returns a list of the nearest placenames in the database:

>>> from iceaddr import nearest_placenames
>>> pn = nearest_placenames(64.148446, -21.944933, limit=1)[0]
>>> print(pn["nafn"])
Landakotsvöllur

Metadata

Get information about the database version, etc.:

>>> from iceaddr import iceaddr_metadata
>>> meta = iceaddr_metadata()
>>> pprint(meta["date_created"].date())
'2025-11-22'

Build process

To build your own version of the package, you need to have Python >=3.9 installed. Then, after (optionally) creating a virtual environment, run the following command from the repository root to install dependencies:

pip install ".[dev,build]"

Then run the following command to build the database:

bash build.sh

This creates an SQLite3 database in the repo root named iceaddr.db. Move this file to src/iceaddr/ and you can now install your own freshly built version of the package:

pip install .

Version History

  • 0.6.1: Updated address and placename data. Added iceaddr_metadata function. Better package metadata. (29/12/2025)
  • 0.6.0: nearest_* functions now use R-Trees for much faster lookups. Added nearest_*_with_dist functions. Updated address and placename data. (22/11/2025)
  • 0.5.10: Updated address and placename data.

Related Skills

View on GitHub
GitHub Stars28
CategoryDevelopment
Updated1mo ago
Forks2

Languages

Python

Security Score

95/100

Audited on Feb 12, 2026

No findings