Skip to main content

pygeoapi-yaml

A pygeoapi provider for YAML files. pygeoapi reads the YAML file directly, so you don't need to convert it to GeoJSON first.

YAML and JSON map almost one to one, so GeoJSON can be written in YAML as it is: a FeatureCollection in a YAML file is served unchanged. YAML adds what is pleasant when you keep data by hand: comments, long texts that stay readable, and clean diffs in git. Data kept by hand is often a plain list of records, as in a CSV file, so the provider reads that too: you say where the id and the geometry are.

This provider publishes such a file as an OGC API - Features collection. The YAML file stays the source of truth. pygeoapi answers in GeoJSON, as it does for every other provider.

Status: alpha, read-only. See Status and roadmap.

Install

pip install pygeoapi-yaml

It needs pygeoapi 0.24 or later, in the same Python environment.

Configure

Declare the provider in your pygeoapi configuration by its Python path. A file can be written in one of three ways.

A list of records, with coordinates in two fields

# observations.yaml
- id: obs-1
  name: Mont Royal
  lat: 45.5
  lon: -73.6
  seen: 2026-05-01
  tags: [birds, park]
- id: obs-2
  name: Somewhere unknown   # no coordinates: geometry is null
  seen: 2026-07-20
providers:
  - type: feature
    name: pygeoapi_yaml.provider.YAMLProvider
    data: /data/observations.yaml
    id_field: id
    title_field: name
    time_field: seen          # optional, enables ?datetime=
    geometry:                 # optional, as in the CSV provider
      x_field: lon
      y_field: lat

Records under a key, with a GeoJSON geometry in a field

# trails.yaml
title: Trails
trails:
  - code: T1
    name: Lakeshore
    path:
      type: LineString
      coordinates: [[-73.60, 45.50], [-73.58, 45.51]]
providers:
  - type: feature
    name: pygeoapi_yaml.provider.YAMLProvider
    data: /data/trails.yaml
    items_key: trails         # where the list is
    id_field: code
    geometry:
      field: path             # a GeoJSON geometry

With no geometry setting at all, every item is served with geometry: null. This is fine for data that isn't spatial.

A GeoJSON FeatureCollection, written in YAML

type: FeatureCollection
features:
  - type: Feature
    id: 123-456
    geometry: {type: Point, coordinates: [125.6, 10.1]}
    properties: {name: Dinagat Islands}

This needs no setting beyond data. id_field is used only for features without an id.

Behaviour

  • Queries. All of these are supported:

    • limit and offset;
    • resulttype=hits;
    • property filters (?name=...);
    • bbox;
    • datetime (an instant or an interval, open with .., on time_field);
    • sortby (several properties allowed);
    • q;
    • properties (select properties);
    • skipGeometry;
    • count: false.
  • Field types are read from all items. Integers and floats in the same field give number. Other mixed types give string. YAML dates give string with format date or date-time, so the queryables are right.

  • YAML values JSON lacks are converted in responses:

    • dates and timestamps become ISO 8601 strings;
    • !!binary becomes base64.
  • Property filters compare typed values: ?count=10 matches 10 and 10.0, and ?checked=true matches a YAML true. If the field holds a list, the filter matches when the list contains the value (?tags=park).

  • q follows OGC API - Records:

    • commas separate alternatives;
    • spaces separate words that must all be found.

    The search ignores case and looks in every text value, including values in lists and nested mappings.

  • bbox never matches an item without geometry. The OGC API - Features specification asks for this. pygeoapi's GeoJSON and CSV providers include such items instead.

  • Sorting puts items without the property last, whether the order is ascending or descending.

  • Ids come from id_field. An item without one gets its position in the list as its id, and a warning is logged, as are duplicate ids.

  • Changes are seen at once. Each file is parsed once, then kept in memory until its modification time or size changes. No restart is needed. pygeoapi creates a provider for each request, so the parsed copy is shared between them.

  • Empty files (empty, only comments, or []) and missing files give an empty collection, not an error.

  • Safe parsing. The provider uses yaml.safe_load, so a YAML file can never build Python objects or run code. An invalid file gives an error response, with the details in the log.

  • Read-only. OGC API - Features - Part 4 (create, replace, update, delete) is not implemented yet. See the roadmap.

Extending

To read another layout, or to compute properties, subclass YAMLProvider and override _features(document). It receives the parsed YAML document and returns GeoJSON features. In the features it returns:

  • values can still be YAML values, such as dates;
  • an id can be None.

The provider still takes care of the rest: ids, field types, conversion to JSON, queries and caching. Each subclass keeps its own parsed copy of a file.

from pygeoapi_yaml.provider import YAMLProvider


class MyProvider(YAMLProvider):
    def _features(self, document):
        features = super()._features(document)
        for feature in features:
            feature['properties']['label'] = feature['properties']['name'].upper()
        return features

Development

python3 -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/pytest
.venv/bin/flake8 pygeoapi_yaml tests

There are two kinds of tests:

  • tests/test_yaml_provider.py tests the provider on its own, in the style of pygeoapi's provider tests.
  • tests/test_api.py goes through pygeoapi itself:
    • the configuration is validated against pygeoapi's schema;
    • the OpenAPI document is generated;
    • /collections, /items, /items/{id}, the queryables and an empty collection are checked.

See CONTRIBUTING.md before opening a pull request.

Status and roadmap

Done (0.1.0, on PyPI):

  • Read-only provider: get_fields, query, get and get_domains.
  • Three file layouts: records, records under items_key, a FeatureCollection.
  • Geometry from x_field/y_field, from a GeoJSON field, or none.
  • Every query parameter pygeoapi passes to a feature provider.
  • The file is read again when it changes; its parsed copy is shared between requests.
  • Subclassing: override _features() to read another layout.
  • Tests for the provider alone and through pygeoapi, checked by mutation testing (each deliberate bug in the provider makes a test fail).
  • Continuous integration: pytest and flake8 on Python 3.12 and 3.13.

Next:

  • CI on both the oldest supported pygeoapi and the latest. For now they are the same: 0.24 is both the minimum and the latest release.
  • Listing on the pygeoapi community plugins page.
  • A cql2 filter (filter=), through pygeofilter, as other providers do.
  • Writing (OGC API - Features - Part 4). This only comes with ruamel.yaml, so that comments and formatting survive a write. Otherwise a write would erase them.
  • A directory of YAML files, one item per file, as a single collection.
  • Then, on top of it, a catalogue of pygeometa MCF files (YAML metadata, one record per file) served as OGC API - Records.

Authorship

Most of the code, tests and documentation were written by Claude, an AI model made by Anthropic, working in Claude Code. Alexandre Leroux started the project, set its goals and made its design decisions, and directed the work. Commits written with Claude carry a Co-Authored-By: Claude trailer.

Whoever types the code, it is held to the same checks: each behaviour has a test, some tests go through pygeoapi itself, and mutation testing shows that the tests catch deliberate bugs.

License

MIT, like pygeoapi. See LICENSE.

Metadata

Release files for pygeoapi-yaml 0.1.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 pygeoapi-yaml 0.1.0
File Size Uploaded Provenance Actions
pygeoapi_yaml-0.1.0.tar.gz 22.6 kB With provenance Details for pygeoapi_yaml-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygeoapi-yaml 0.1.0
File Interpreter ABI Platform Actions
pygeoapi_yaml-0.1.0-py3-none-any.whl Python 3 none any Details for pygeoapi_yaml-0.1.0-py3-none-any.whl

Total release size: 36.0 kB

Release files / pygeoapi_yaml-0.1.0.tar.gz

Download URL pygeoapi_yaml-0.1.0.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aa44accec0458ed63261c49f3f4f3ec5d53ead9c8955a480f9f017e6a23aa5fa
BLAKE2b-256 checksum
How to use checksums
6a06aa480359c0dfa5a9d209e6658ce988099525b530fac899228cd7d157b832
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 21, 2026.

Transparency log

Release files / pygeoapi_yaml-0.1.0-py3-none-any.whl

Download URL pygeoapi_yaml-0.1.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e612bda626e577b7cad60a4fb77c70573b98edde7790aff477f7a5bb31827385
BLAKE2b-256 checksum
How to use checksums
377257e7c2fa6c535bf70ac96a3f21a515e048174afbfcb7451217db54fb2c41
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 21, 2026.

Transparency log

Security for pygeoapi-yaml 0.1.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 pygeoapi_yaml-0.1.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 21, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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