Skip to main content

pygeoapi-plugins

pygeoapi plugins developed by the Center for Geospatial Solutions

OGC API - Features

Additional OGC API - Feature providers are listed below, along with a matrix of supported query parameters.

Provider Property Filters/Display Result Type BBox Datetime Sort By Skip Geometry CQL Transactions CRS
CKAN ✅/✅ results/hits
PsuedoPostgreSQL ✅/✅ results/hits
SPARQL ❌/✅ results/hits
GeoPandas ✅/✅ results/hits

The provider names listed in the table are only accessible in internetofwater/pygeoapi, otherwise the full python path is required.

CKAN

The CKAN Provider enables OGC API - Feature support at the collection level for a specific resource within the datastore-search endpoints of CKAN instances. It allows you to integrate CKAN resources into your pygeoapi instance. The provider definition for the CKAN Provider includes configuration options specific to CKAN. To use the CKAN Provider, you need to specify pygeoapi_plugins.provider.ckan.CKANProvider as the provider's name.

providers:
  - type: feature
    name: pygeoapi_plugins.provider.ckan.CKANProvider
    data: https://catalog.newmexicowaterdata.org/api/3/action/datastore_search
    resource_id: 08369d21-520b-439e-97e3-5ecb50737887
    id_field: _id
    x_field: LONDD
    y_field: LATDD

In this example, the CKAN Provider is configured to work with the specified CKAN resource.

  • data: The URL endpoint for the datastore search API of the CKAN instance.
  • resource_id: The identifier of the specific CKAN resource you want to access within the datastore.
  • id_field: The field that serves as the unique identifier for features in the CKAN resource.
  • x_field: The field representing the X-coordinate (longitude) for the features in the CKAN resource.
  • y_field: The field representing the Y-coordinate (latitude) for the features in the CKAN resource.

PseudoPostgresSQL

The PseudoPostgresSQL Provider adds a simple capacity to the PostgresSQL Provider in pygeoapi core - faster counting. This is done by performing a pseudo-count on tables exceeding a definable limit. The limit is defined using the PSEUDO_COUNT_LIMIT environment variable. To use the PseudoPostgresSQL Provider, you need to specify pygeoapi_plugins.provider.postgresql.PseudoPostgreSQLProvider as the provider's name.

SPARQL

The SPARQL Provider is a wrapper for any pygeoapi feature provider that provides additional context, allowing integration of SPARQL-based data sources into a pygeoapi instance. By wrapping another feature provider, the SPARQL Provider inherits queryable capacities from the wrapped feature provider - adding SPARQL context to each resulting feature. The provider definition for the SPARQL Provider is similar to that of the wrapped provider, with the addition of specific SPARQL-related configuration options. To use the SPARQL Provider, you need to specify pygeoapi_plugins.provider.sparql.SPARQLProvider as the provider's name.

providers:
  - # Normal pygeoapi provider configuration
    type: feature
    data: /pygeoapi_plugins/tests/data/places.csv
    id_field: index
    geometry:
      x_field: lon
      y_field: lat
    #
    name: pygeoapi_plugins.provider.sparql.SPARQLProvider
    sparql_provider: CSV # Name of provider SPARQL is wrapping
    sparql_query:
      endpoint: https://dbpedia.org/sparql
      bind:
        name: uri
        variable: '?subject'
      prefixes:
        '': <http://dbpedia.org/resource/>
        dbpedia2: <http://dbpedia.org/property/>
        dbo: <http://dbpedia.org/ontology/>
      where:
        - subject: '?subject'
          predicate: dbo:populationTotal
          object: '?population'
        - subject: '?subject'
          predicate: dbo:country
          object: '?country'
        - subject: '?subject'
          predicate: '<http://dbpedia.org/property/leaderName>'
          object: '?leader'
      filter:
        - 'FILTER (isIRI(?leader) || isLiteral(?leader))'

In this example, the SPARQL Provider wraps the GeoJSON Provider. The SPARQL Provider only uses variables prefixed with sparql_ in the configuration.

  • data: The path to the data file used by the wrapped provider (GeoJSON Provider in this case).
  • id_field: The field that serves as the unique identifier for features in the data.
  • sparql_provider: The name of the provider that will handle the SPARQL query results (GeoJSON Provider in this case).
  • sparql_query: The SPARQL object holding the content of the SPARQL query.
    • endpoint: The SPARQL variable representing the graph IRI in the query.
    • bind:
      • name: Field in the wrapped properties block to query the graph with
      • variable: The SPARQL variable used for querying (e.g., ?subject). prefixes:
    • prefixes: Optional dictionary defining the prefixes used in the SPARQL query.
    • where: A list of mappings that define the WHERE clause of the SPARQL query. Each mapping includes:
      • subject: The subject of the triple pattern.
      • predicate: The predicate of the triple pattern.
      • object: The object of the triple pattern.
    • filter: A list of SPARQL filter expressions to apply to the results.

GeoPandas

The GeoPandas Provider enables OGC API - Feature support using GeoPandas as the backend. This integration can read in data files in any of the geospatial formats supported by GeoPandas.

id_field is the only field that is required to be labeled.

providers:
  - type: feature
    name: pygeoapi_plugins.provider.geopandas_.GeoPandasProvider
    # Example data
    data: 'https://www.hydroshare.org/resource/3295a17b4cc24d34bd6a5c5aaf753c50/data/contents/hu02.gpkg'
    id_field: id

You can also use plain CSV and read in points by providing an x_field and y_field in the config the same way you would with the default pygeoapi CSV provider.

OGC API - Tiles

Additional OGC API - Tile providers are listed below

MVT PostgreSQL

The MVT PostgreSQL Provider extends the core provider, to include additional supports for rendering features efficiently at low zoom. The threshold for applying limits can be controlled with the configuration option disable_at_z. The default value for the zoom threshold is 6.

The first way to filter the features that are rendered is by setting a minimum pixel size. The configuration option min_pixel provider will drop features that are less than a pixel in the rendered tile. The default value for minimum pixel size is 512. The following configuration would render half pixel features until zoom level 10.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    ...
    disable_at_z: 10
    mix_pixel: 256 # a full pixel in the tile

The second way to filter the features that are rendered in a tile is using a modified CQL expression. The CQL expression can be used to determine render priority based on non-geographic attributes of a feature The following configuration would only render features with a population larger than 100,000:

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    ...
    tile_threshold: "population > 100000"

The CQL expression can be formatted with a z value (minimum zoom is 1). This allows the parameter filter to be dynamic based on the zoom level of the tile. The following configuration would render tiles of successively smaller populations for every subsequent zoom level increase:

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    ...
    disable_at_z: 5
    tile_threshold: "population_served_count > 200000 / ({z} * 2)"
    # z{0}: population_served_count > 100000
    # z{1}: population_served_count > 100000
    # z{2}: population_served_count > 50000
    # z{3}: population_served_count > 33333
    # z{4}: population_served_count > 25000

The third configuration option tile_limit can be specified to enforce a maximum number of features in a single tile. This will apply to all tiles regardless of if the other filters are enabled by disable_at_z. Features will be ordered by the size of there bounding box, pruning the smallest feature until the feature limit is met for the tile. Point-based geometry are pruned at random.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    ...
    disable_at_z: 0 # Apply no CQL or Pixel Size filter
    tile_limit: 1000 # No more than 1000 features in a single tile

The fourth configuration option simplify_geometry can be specified to reduce the number of vertices at low zooms. This will apply to all tiles regardless of if the other filters are enabled by disable_at_z.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    simplify_geometry: true
    # Simplification tolerance value scales with zoom level:
    #   z{0}: tolerance = 0.1
    #   z{2}: tolerance = 0.1
    #   z{4}: tolerance = 0.01
    #   z{6}: tolerance = 0.001
    #   z{8}: tolerance = 0.0001
    simplify_method: ST_SimplifyPreserveTopology # default
    # Must be one of:
    #   ST_Simplify
    #   ST_SimplifyPreserveTopology
    #   ST_SimplifyVW
    #   ST_SnapToGrid
    ...

The fifth configuration option tile_limit can be specified to enforce a maximum size (in Mb) for a single tile. This will apply to all tiles regardless of if the other filters are enabled by disable_at_z.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_postgresql.MVTPostgreSQLProvider_
    ...
    disable_at_z: 0 # Apply no CQL or Pixel Size filter
    tile_size: 10 # Tile size shall be no more than 10Mb

MVT PostgreSQL with Caching

There are two additional Postgres based MVT providers with caching of tiles to prevent significant server load on tile generation at low zoom levels. Both providers use the configuration option disable_cache_at_z to prevent storing tiles at high zoom levels if undesired.

Filesystem Cache

The filesystem cache uses a local filesystem to store pbf blobs in a typical z/y/x directory tree.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_cache.MVTPostgresFilesystem
    ...
    cache_directory: /tmp/mvt_cache # Default directory if not specified
    disable_cache_at_z: 6 # Default value to disable caching if not specified

PostgreSQL Table Cache

The table cache uses an external table to store pbf blobs in a typical z/y/x relational database. Make sure the credentials have access to update the table and write if necessary.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_cache.MVTPostgresCache
    ...
    table: osm_waterways
    mvt_table: osm_waterways_mvt # Default table is table with `_mvt` appended
    disable_cache_at_z: 25 # Cache everything (eventually)

Redis Cache

The Redis cache uses a combined tile key for the lookup in a Redis service.

providers:
  - type: tile
    name: pygeoapi_plugins.provider.mvt_cache.MVTPostgresRedis
    ...
    redis_host: ${REDIS_HOST} # Use REDIS_HOST from environment
    redis_port: ${REDIS_PORT} # Use REDIS_PORT from environment

OGC API - Processes

Additional OGC API - Processes are listed below

Intersector

The intersection process uses GDAL Python bindings to return features from a collection using an existing Geospatial OGR based file as the spatial mask.

An example configuration in a pygeoapi configuration is below.

intersector:
  type: process
  processor:
    name: pygeoapi_plugins.process.intersect.IntersectionProcessor
  • collection is always required
  • url or file is required
    • url is the remote source of the Geospatial file
    • file is the encoded bytes of the Geospatial file

This plugin is used in https:/reference.geoconnex.us/.

Sitemap Generator

The Sitemap Generator process makes use of the XML formatter and OGC API - Features to generate a sitemap of the pygeoapi instance. This can be used with the python package sitemap-generator to generate a sitemap index. An example configuration in a pygeoapi configuration is below.

sitemap-generator:
  type: process
  processor:
    name: pygeoapi_plugins.process.sitemap.SitemapProcessor

Formatters

The pygeoapi plugins repository includes a variety of custom formatters to modify the response body from OGC API - Feature and OGC API - EDR GeoJSON responses. The following formatters are supported:

  • JSON-FG: pygeoapi_plugins.formatter.JSONFG — returns JSON-FG compliant GeoJSON (application/geo+json). Useful for systems that require OGR-style JSON-FG output.
  • Parquet: pygeoapi_plugins.formatter.Parquet — returns an Apache Parquet binary (application/vnd.apache.parquet). Good for analytical workflows and columnar storage.
  • Shapefile: pygeoapi_plugins.formatter.Shapefile — returns a zipped Shapefile (application/zip).
  • KML: pygeoapi_plugins.formatter.KML — returns KML formatted output (application/vnd.google-earth.kml+xml).
  • GPKG: pygeoapi_plugins.formatter.GPKG — returns a GeoPackage (application/geopackage+sqlite3).
  • PGDUMP: pygeoapi_plugins.formatter.PGDUMP — returns SQL dump suitable for importing into PostGIS (application/sql).
  • XML (Sitemap): pygeoapi_plugins.formatter.XML — generates a sitemap XML from feature collections (application/xml).

Usage

  • To enable any of these formatters for a resource, add them to the resource formatters list in your pygeoapi configuration. Example (see docker/pygeoapi.config.yml for a full example):
resources:
  my_collection:
    type: collection
    title: My Collection
    providers:
      - type: feature
        name: pygeoapi_plugins.provider.geopandas_.GeoPandasProvider
        data: /path/to/data.geojson
        id_field: id
    formatters:
      - name: pygeoapi_plugins.formatter.JSONFG
      - name: pygeoapi_plugins.formatter.Shapefile
      - name: pygeoapi_plugins.formatter.GPKG
      - name: pygeoapi_plugins.formatter.KML
      - name: pygeoapi_plugins.formatter.PGDUMP
      - name: pygeoapi_plugins.formatter.XML
      - name: pygeoapi_plugins.formatter.Parquet

Download files

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

Source Distribution

pygeoapi_plugins-0.6.0.tar.gz (148.1 kB view details)

Uploaded Source

Built Distribution

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

pygeoapi_plugins-0.6.0-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file pygeoapi_plugins-0.6.0.tar.gz.

File metadata

  • Download URL: pygeoapi_plugins-0.6.0.tar.gz
  • Upload date:
  • Size: 148.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pygeoapi_plugins-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0b156a98e1937f069ad845ea8e091692c716e4127becc7846d36b374a8e5f969
MD5 c20b5904ad056e63cd1670c5b83ed312
BLAKE2b-256 262f412549942bd4b25f67a9599c3a77dfe7b5b96190f183fc5974979e09db70

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygeoapi_plugins-0.6.0.tar.gz:

Publisher: pypi.yml on cgs-earth/pygeoapi-plugins

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

File details

Details for the file pygeoapi_plugins-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pygeoapi_plugins-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6b7f2a5ada202d84003d75c379a62f6d4fefd42e8a20158e9918f8b9867a947
MD5 3a32a387d064e27b813c2ff75b393f04
BLAKE2b-256 80d448154e1478a2f08a4257abfee96c2b7a64aa0158e4bf2b6516f27877c780

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygeoapi_plugins-0.6.0-py3-none-any.whl:

Publisher: pypi.yml on cgs-earth/pygeoapi-plugins

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

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

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