Skip to main content

Django app for importing and managing OurAirports data (airports, runways, frequencies, navaids)

Project description

django-ourairports

A Django application to download and import aviation data from OurAirports.

Features

  • Import airports, runways, frequencies, navaids, countries, and regions
  • GeoDjango support for spatial queries
  • Customizable import via plugin hooks
  • Management command for easy data management
  • Incremental updates with change detection

Requirements

  • Python 3.10+
  • Django 4.2+
  • PostGIS (recommended) or SpatiaLite
  • GDAL

Installation

pip install django-ourairports

Add to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'django.contrib.gis',
    'ourairports',
]

Run migrations:

python manage.py migrate ourairports

Quick Start

Import all data:

python manage.py ourairports --import=all

Import specific data types:

python manage.py ourairports --import=airport,runway

Flush and reimport:

python manage.py ourairports --flush=all --import=all

Configuration

Optional settings in settings.py:

OURAIRPORTS = {
    # Directory for downloaded data files
    'DATA_DIR': '/path/to/data',

    # Cache duration in seconds (default: 86400 = 24 hours)
    'CACHE_DURATION': 86400,

    # Batch size for bulk operations
    'BATCH_SIZE': 1000,
}

Models

Country

Country information with ISO codes and continent.

Region

Administrative regions (states, provinces) with ISO 3166-2 codes.

Airport

Airports with location, type, codes (IATA, ICAO/GPS), and metadata.

Runway

Runway details including dimensions, surface, lighting, and end coordinates.

Frequency

Radio frequencies (TWR, APP, ATIS, etc.) for airports.

Navaid

Navigation aids (VOR, NDB, DME, TACAN) with locations and frequencies.

Usage Examples

from ourairports.models import Airport, Country, Runway

# Find airports by IATA code
jfk = Airport.objects.get(iata_code='JFK')

# Find large airports in a country
us_large = Airport.objects.filter(
    iso_country='US',
    airport_type='large_airport'
)

# Airports with scheduled service
scheduled = Airport.objects.filter(scheduled_service=True)

# Find airports near a point (requires PostGIS)
from django.contrib.gis.geos import Point
from django.contrib.gis.measure import D

point = Point(-73.7781, 40.6413)  # JFK coordinates
nearby = Airport.objects.filter(
    location__distance_lte=(point, D(km=50))
)

# Get runways for an airport
runways = jfk.runways.all()

# Get frequencies for an airport
frequencies = jfk.frequencies.filter(frequency_type='TWR')

Management Command

# Show help
python manage.py ourairports --help

# Import all data
python manage.py ourairports --import=all

# Import specific types
python manage.py ourairports --import=country,region,airport

# Flush data before import
python manage.py ourairports --flush=airport --import=airport

# Force re-download (ignore cache)
python manage.py ourairports --import=all --force

# Dry run (parse without saving)
python manage.py ourairports --import=airport --dry-run

# Download only (no import)
python manage.py ourairports --download-only

# List cached files
python manage.py ourairports --list

# Clear cache
python manage.py ourairports --clear

Import Options

Option Description
country Countries
region Regions (states/provinces)
airport Airports
runway Runways
frequency Radio frequencies
navaid Navigation aids
all All of the above

Plugin System

Customize imports with hooks:

# yourapp/plugins.py
from ourairports.plugin import HookException

def airport_pre(row, importer):
    """Called before each airport is processed."""
    # Skip closed airports
    if row.get('type') == 'closed':
        raise HookException("Skipping closed airport")
    return row

def airport_post(airport, row, importer):
    """Called after each airport is saved."""
    # Add custom processing
    pass

Register in settings:

OURAIRPORTS = {
    'PLUGINS': ['yourapp.plugins'],
}

Data Source

Data is sourced from OurAirports, a community-maintained database of airports worldwide. The data is released to the public domain.

Disclaimer

This project is not affiliated with, endorsed by, or associated with OurAirports or its maintainers. It is an independent, third-party Django integration that consumes publicly available OurAirports data.

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ourairports-0.1.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ourairports-0.1.0-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file django_ourairports-0.1.0.tar.gz.

File metadata

  • Download URL: django_ourairports-0.1.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_ourairports-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1dd0b6e14ad15a2bf68f8cf9b68b0c83cf86c6b946ea1737430a2e81a81b5b22
MD5 b1d02a1947acb6ea0d00def6a95ef963
BLAKE2b-256 88ca0c1b0b6d6fe4df0d1d22966066b731667af62df1f595e968d4e926b64f05

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ourairports-0.1.0.tar.gz:

Publisher: publish.yml on arthanson/django-ourairports

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_ourairports-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ourairports-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caa0a4d2cf3deb000dc78cfd06c976f18bdfedd5bf6ca09d5760064c0f734131
MD5 7dfe9cc10b91424f3aa774e68871f39e
BLAKE2b-256 db1905d1c8398c3a0c225aa0d948756b79567c3998cb1fc47d44e7c2c67c63fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ourairports-0.1.0-py3-none-any.whl:

Publisher: publish.yml on arthanson/django-ourairports

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page