Skip to main content

NeoBase actions cratev crated

Minimalist GeoBases implementation:

  • no dependencies

  • compatible with Python 3.11+, CPython and PyPy

  • one data source: opentraveldata

  • one Python module for easier distribution on clusters (like Hadoop)

  • faster load time (5x)

  • tested with pytest and tox

  • passes static typing checks with ty

>>> from neobase import NeoBase
>>> b = NeoBase()
>>> b.get('ORY', 'city_code_list')
['PAR']
>>> b.get('ORY', 'city_name_list')
['Paris']
>>> b.get('ORY', 'country_code')
'FR'
>>> b.distance('ORY', 'CDG')
34.87...
>>> b.get_location('ORY')
LatLng(lat=48.72..., lng=2.35...)

Installation

Use the Python package:

pip install neobase

Docs

Check out readthedocs for the API.

You can customize the source data when initializing:

with open("file.csv") as f:
    N = NeoBase(f)

Otherwise the loaded file will be the embedded one, unless the OPTD_POR_FILE environment variable is set. In that case, it will load from the path defined in that variable.

You can manually retrieve the latest data source yourself too, but you expose yourself to some breaking changes if they occur in the data.

from io import StringIO
from urllib.request import urlopen

from neobase import NeoBase, OPTD_POR_URL

data = urlopen(OPTD_POR_URL).read().decode('utf8')
N = NeoBase(StringIO(data))
N.get("PAR")

The reference date of validity can be changed as well:

N = NeoBase(date="2000-01-01")
N.get("AIY")  # was decommissioned in 2015

By default, the reference date will be set to today, unless the OPTD_POR_DATE environment variable is set. In that case, it will use that value.

You can customize the behavior regarding duplicates: points sharing the same IATA code, like NCE as airport and NCE as city. By default everything is kept, but you can set it so that only the first point with an IATA code is kept:

N = NeoBase(duplicates=False)
len(N)  # about 10,000 "only"

Note that you can use the OPTD_POR_DUPLICATES environment variable to control this as well: set it to 0 to drop duplicates.

Finally, you can customize fields loaded by subclassing.

class SubNeoBase(NeoBase):
    KEY = 0  # iata_code

    # Those loaded fields are the default ones
    FIELDS = (
        ("name", 6, None),
        ("lat", 8, None),
        ("lng", 9, None),
        ("page_rank", 12, lambda s: float(s) if s else None),
        ("country_code", 16, None),
        ("country_name", 18, None),
        ('continent_name', 19, None),
        ("timezone", 31, None),
        ("city_code_list", 36, lambda s: s.split(",")),
        ('city_name_list', 37, lambda s: s.split('=')),
        ('location_type', 41, None),
        ("currency", 46, None),
    )

N = SubNeoBase()

Command-line interface

You can query the data using:

python -m neobase PAR NCE

Tests

tox

A note about performance

The geographical operations like N.find_near("ORY", 100) or N.find_closest_from("ORY") perform a full scan of the data, and are not optimized (remember that this library has no dependencies, by design).

If you want a more efficient solution, you should use a spatial index like a BallTree, for example using scikit-learn:

import numpy as np
from sklearn.neighbors import BallTree
from neobase import NeoBase

N = NeoBase()

iata_codes = []
coords = []
for key in N:
    lat, lon = N.get_location(key)
    if lat is not None and lon is not None:
        iata_codes.append(N.get(key, "iata_code"))
        coords.append([np.radians(lat), np.radians(lon)])
coords = np.array(coords)

tree = BallTree(coords, metric="haversine")

def find_closest_with_balltree(coord):
    point = np.radians(coord)
    _, idx = tree.query([point], k=1)
    iata_code = iata_codes[idx[0][0]]
    return iata_code

paris = (48.8566, 2.3522)
print(find_closest_with_balltree(paris))  # <0.1ms
print(list(N.find_closest_from_location(paris)))  # ~30ms

Metadata

Release files for NeoBase 0.37

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

Source distribution (sdist)

Source distribution for NeoBase 0.37
File Size Uploaded
neobase-0.37.tar.gz 4.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for NeoBase 0.37
File Interpreter ABI Platform
neobase-0.37-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 MB

Release files / neobase-0.37.tar.gz

Download URL neobase-0.37.tar.gz
Size 4.2 MB
Tags Source
SHA-256 checksum
How to use checksums
ca44928c75214344f80f2afb0eecc4e395a50a5413ee635b81ccb80772c7f1ba
BLAKE2b-256 checksum
How to use checksums
cac8d2c70ac7be9a5026a2e66b2713eaf0bb56a9fda229b5a4273ecd887f74a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 26, 2026.

Transparency log

Release files / neobase-0.37-py3-none-any.whl

Download URL neobase-0.37-py3-none-any.whl
Size 4.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
761a0beacade63d3d7a8b62cc079b6e9b50843df728a56f315797566a3291bf4
BLAKE2b-256 checksum
How to use checksums
e1604a99fb894400153f8a8999caa143e807d3acb44494b2544a08939cd34879
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.37 This release

2 release files

0.36.4

2 release files

0.36.3

2 release files

0.36.2

2 release files

0.36.1

2 release files

0.36

2 release files

0.35

2 release files

0.34.9

2 release files

0.34.8

2 release files

0.34.7

2 release files

0.34.5

2 release files

0.34.4

2 release files

0.34.3

2 release files

0.34.2

2 release files

0.34.1

2 release files

0.34

2 release files

0.33.9

2 release files

0.33.8

2 release files

0.33.7

2 release files

0.33.6

2 release files

0.33.5

2 release files

0.33.4

2 release files

0.33.2

2 release files

0.33

2 release files

0.32.4

2 release files

0.32.2

2 release files

0.32.1

2 release files

0.32

2 release files

0.31.6

2 release files

0.31.5

2 release files

0.31.4

2 release files

0.31.3

2 release files

0.31.2

2 release files

0.31.1

2 release files

0.31

2 release files

0.30.8

2 release files

0.30.4

2 release files

0.30.2

2 release files

0.30.1

2 release files

0.30

2 release files

0.29.6

2 release files

0.29.5

2 release files

0.29.4

2 release files

0.29.3

2 release files

0.29.2

2 release files

0.29.1

2 release files

0.29

2 release files

0.28

2 release files

0.27.4

2 release files

0.27.3

2 release files

0.27.1

2 release files

0.27

2 release files

0.26.2

2 release files

0.26

2 release files

0.25.2

2 release files

0.25

2 release files

0.24

2 release files

0.23

2 release files

0.22

2 release files

0.21.2

1 release file

0.21.1

1 release file

0.21

1 release file

0.20.6

1 release file

0.20.5

1 release file

0.20.4

1 release file

0.20.3

1 release file

0.20.2

1 release file

0.20.1

1 release file

0.20

1 release file

0.19.1

1 release file

0.19

1 release file

0.18.4

1 release file

0.18.3

1 release file

0.18.2

1 release file

0.18.1

1 release file

0.18

1 release file

0.17.4

1 release file

0.17.3

1 release file

0.17.2

1 release file

0.17.1

1 release file

0.17

1 release file

0.16.1

1 release file

0.16

1 release file

0.15

1 release file

0.14

1 release file

0.13

1 release file

0.12

1 release file

0.11

1 release file

0.10

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

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