Skip to content

SpatialDays/stac-fastapi-pgstac

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stac-fastapi-pgstac

Fork of https://github.com/stac-utils/stac-fastapi-pgstac

Environment variables

Var name Used for
APP_HOST Host address for the application.
APP_PORT Port number for the application.
RELOAD Flag indicating whether the application should reload.
POSTGRES_USER PostgreSQL username.
POSTGRES_PASS PostgreSQL password.
POSTGRES_DBNAME PostgreSQL database name.
POSTGRES_HOST_READER Hostname for reading from the PostgreSQL server.
POSTGRES_HOST_WRITER Hostname for writing to the PostgreSQL server.
POSTGRES_PORT PostgreSQL port number.
DB_MIN_CONN_SIZE Minimum number of database connections in the pool.
DB_MAX_CONN_SIZE Maximum number of database connections in the pool.
WEB_CONCURRENCY Number of worker processes for the application.
VSI_CACHE Flag indicating whether VSI cache should be enabled.
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES Flag indicating whether GDAL should merge consecutive ranges.
GDAL_DISABLE_READDIR_ON_OPEN Flag indicating whether GDAL should disable readdir on open.

What changed in the fork

  • Self-initializing PgSTAC schema added
  • Custom Dockerfile
  • Custom new entrypoint script
  • Build actions for Docker image on ACR
  • Removed publishing to PyPI from GitHub Actions

GitHub Workflow Status PyPI Documentation License

FastAPI

PgSTAC backend for stac-fastapi, the FastAPI implementation of the STAC API spec

Overview

stac-fastapi-pgstac is an HTTP interface built in FastAPI. It validates requests and data sent to a PgSTAC backend, and adds links to the returned data. All other processing and search is provided directly using PgSTAC procedural sql / plpgsql functions on the database. PgSTAC stores all collection and item records as jsonb fields exactly as they come in allowing for any custom fields to be stored and retrieved transparently.

Usage

PgSTAC is an external project and may be used by multiple front ends. For Stac FastAPI development, a Docker image (which is pulled as part of the docker-compose) is available via the Github container registry. The PgSTAC version required by stac-fastapi-pgstac is found in the setup file.

Sorting

While the STAC Sort Extension is fully supported, PgSTAC is particularly enhanced to be able to sort by datetime (either ascending or descending). Sorting by anything other than datetime (the default if no sort is specified) on very large STAC repositories without very specific query limits (ie selecting a single day date range) will not have the same performance. For more than millions of records it is recommended to either set a low connection timeout on PostgreSQL or to disable use of the Sort Extension.

Hydration

To configure stac-fastapi-pgstac to hydrate search result items in the API, set the USE_API_HYDRATE environment variable to true or explicitly set the option in the PGStac Settings object.

Migrations

There is a Python utility as part of PgSTAC (pypgstac) that includes a migration utility. To use:

pypgstac migrate

Contributing

See CONTRIBUTING for detailed contribution instructions.

To install:

git clone https://github.com/stac-utils/stac-fastapi-pgstac
cd stac-fastapi-pgstac
pip install -e ".[dev,server,docs]"

To test:

make test

Use Github Pull Requests to provide new features or to request review of draft code, and use Issues to report bugs or request new features.

Documentation

To build the docs:

make docs

Then, serve the docs via a local HTTP server:

mkdocs serve

History

stac-fastapi-pgstac was initially added to stac-fastapi by developmentseed. In April of 2023, it was removed from the core stac-fastapi repository and moved to its current location (http://github.com/stac-utils/stac-fastapi-pgstac).

License

MIT

About

PostgreSQL backend for stac-fastapi using pgstac (https://github.com/stac-utils/pgstac)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PLpgSQL 61.4%
  • Python 36.4%
  • Shell 1.9%
  • Other 0.3%