pygeoapi Documentation
repository·master·Indexed 20 days ago
https://github.com/geopython/pygeoapiA Python server implementation of the OGC API standards suite for deploying RESTful geospatial API endpoints using OpenAPI, GeoJSON, and HTML. Includes guides on Docker deployment, server configuration, OGR provider setup, Admin API management, and OpenAPI document generation.
What's inside pygeoapi
- pygeoapi is a Python-based server implementation of the OGC API suite of standards. It allows organizations to deploy RESTful OGC API endpoints using OpenAPI, GeoJSON, and HTML. It is built on a plugin framework, making it flexible for custom data connections, formats, and processes. It supports multiple Python web frameworks, including Flask (default) and Starlette, and supports asynchronous processing for job management.
Overview of publishing in pygeoapi
masterpygeoapi allows you to integrate and publish various geospatial assets through a plugin-based architecture. You can publish:
- Data: Vector and coverage data, including filesystems, databases, and cloud storage.
- Metadata: Geospatial metadata (data about data) using standards like STAC or OGC API - Records.
- Processes: Executable workflows via the OGC API - Processes standard.
The system relies on a plugin framework for data providers, metadata providers, and processes. For developers looking to extend these capabilities, refer to the custom plugin documentation.
Publishing files to a SpatioTemporal Asset Catalog (STAC)
masterThe SpatioTemporal Asset Catalog (STAC) is a specification for standardizing geospatial asset metadata (e.g., satellite imagery, LiDAR, vector data, etc.) to enable structured querying based on place and time.
pygeoapi includes built-in providers that allow users to browse and interact with STAC catalogs. This enables the discovery and access of spatiotemporal assets through standardized interfaces.
Key Features and Capabilities of pygeoapi
masterpygeoapi offers several out-of-the-box capabilities for geospatial data serving:
- Data Providers: Includes plugins for
rasterio,GDAL/OGR,Elasticsearch, andPostgreSQL/PostGIS. - Output Formats: Supports
JSON,GeoJSON,HTML, andCSV. - Querying: Supports data filtering via spatial, temporal, or attribute queries.
- Documentation: Provides OpenAPI / Swagger documentation for developers.
- Configuration: Uses simple YAML configuration files.
- Deployment: Can be installed via
piporgit, and deployed using UbuntuGIS or the official Docker image.
- Data Providers: Includes plugins for
Overview of pygeoapi plugin architecture
masterpygeoapi uses a plugin architecture to extend its functionality across several subsystems. Developers can implement custom logic for data providers, output formats, processes, and the process manager. The core plugin registry is located at
pygeoapi.plugin.PLUGINS.Each plugin type must implement a specific base class to satisfy the API contract:
- Data Providers:
features/records/maps:pygeoapi.provider.base.BaseProvideredr:pygeoapi.provider.base_edr.BaseEDRProvidertiles:pygeoapi.provider.tile.BaseTileProvider
- Output Formats:
pygeoapi.formatter.base.BaseFormatter - Processes:
pygeoapi.process.base.BaseProcessor - Process Manager:
pygeoapi.process.manager.base.BaseManager
- Data Providers:
Handle process responses (Raw vs Document)
masterpygeoapi handles process outputs in two primary ways via the
responseparameter in the execution request:- Raw (Default): Returns the response in its native encoding and media type as defined by the plugin. Use
response: raw(or omit the parameter) to achieve this. - Document: Returns a JSON-encoded response that embeds the resulting payload (binary data may be Base64 encoded). Use
response: documentto achieve this.
- Raw (Default): Returns the response in its native encoding and media type as defined by the plugin. Use
Understand pygeoapi security and access control
masterBy design, pygeoapi does not include built-in support for authentication or authorization. It does not manage user roles, groups, or fine-grained access control (e.g., restricting access to specific collections or processes) internally.
To implement security, you must use an external framework or a third-party project designed to run atop pygeoapi. Depending on your requirements, you can implement anything from simple HTTP Basic Authentication to complex access control models.
Configure access control for the Admin API
masterpygeoapi does not handle authentication or authorization for the Admin API. If you enable the Admin API, you are responsible for providing access control explicitly via an external service to prevent unauthorized configuration changes.Configure CRS and Bounding Box defaults for OGC API - Maps
masterWhen requesting maps via OGC API - Maps, the following CRS and Bounding Box behaviors apply:
Coordinate Reference Systems (CRS): Supported formats include URIs or CURIEs:
http://www.opengis.net/def/crs/EPSG/0/4326[EPSG:4326]EPSG:4326(unsafe)CRS:84(unsafe)OGC:CRS84(unsafe)
Defaults:
- If
crsis not provided, the server defaults tostorage_crs. Ifstorage_crsis missing, it defaults toCRS84. - If
crs-bboxis not provided, it defaults toCRS84. - If
bboxis not provided, it defaults to-180, -90, 180, 90.
Response Headers: Every response includes
Content-CrsandContent-Bboxheaders.Create hierarchical collections
masterBy default, all collections are published at
/collections. You can create a hierarchy by using slashes in the resource key within theresourcessection.Example:
resources: naturalearth/lakes: ...This makes the collection available at
/collections/naturalearth/lakes.Note: Currently, pygeoapi does not support collection grouping. Navigating to the parent path (e.g.,
/collections/naturalearth) will not provide an aggregate list of sub-collections.Supported OGC API Standards in pygeoapi
masterpygeoapi provides varying levels of support for OGC standards. It acts as a Reference Implementation for several key standards, meaning it serves as a primary example of how the standard should be implemented.
Reference Implementations:
- OGC API - Features
- OGC API - Tiles
- OGC API - Environmental Data Retrieval
Compliant Standards:
- OGC API - Processes
Implemented Standards:
- OGC API - Coverages
- OGC API - Maps
- OGC API - Records
- SpatioTemporal Asset Catalog (STAC)
How the HATEOAS STAC Provider works
masterThe
Hateoasprovider implements a REST application where clients navigate resources via hypermedia links. This requires a specific directory structure and link format to ensure the catalog can be moved or copied without breaking.Link Rules
- Structural links (
root,parent,child,item,collection) must use relative URLs. - Asset links must use absolute URLs.
- No
selflink should be used (as it would require an absolute URL).
Directory Structure Rules
- Root documents: Catalogs must be named
catalog.json; Collections must be namedcollection.json. - Hierarchy: Sub-Catalogs/Collections must be in subdirectories (max 1 level deeper than the parent document).
- Items: Must be named
<id>.jsonand stored in a unique subdirectory named after the<id>(e.g.,item_id/item_id.json). - Consistency: Use structural elements (Catalog/Collection) consistently across hierarchy levels.
// Example catalog.json structure { "id": "STAC-Catalog", "type": "Catalog", "stac_version": "1.0.0", "links": [ { "rel": "root", "href": "./catalog.json", "type": "application/json" }, { "rel": "child", "href": "./eo4ce/catalog.json", "type": "application/json" } ] }- Structural links (