Skip to main content

GeoPackage schema for validating and storing vector geologic map data produced by computer-vision pipelines

Project description

CriticalMAAS TA1 geopackage library

This repository contains schema definitions and a reference Python library for manipulating a GeoPackage-based data transfer format for CriticalMAAS TA1, based on the TA1 output schemas. It was created by the Macrostrat TA4 team and will be maintained jointly by TA1 and TA4 as the schema is updated.

Installation

This package is listed as criticalmaas.ta1-geopackage on PyPI. It can be installed with standard Python semantics:

# PIP installation
pip install criticalmaas.ta1-geopackage
# Poetry
poetry add criticalmaas.ta1-geopackage

The package can also be installed directly from GitHub, e.g. pip install git+https://github.com/DARPA-CRITICALMAAS/ta1-geopackage.git.

If you are not using Python, you can load the schema directly from the criticalmaas/ta1_geopackage/fixtures directory, and use other tools such as ogr2ogr to load data into the database.

Examples

Example maps (output from Macrostrat's CLI writer):

At the moment, these only show final feature datasets (e.g. polygon_feature) for digital-native maps. Examples of TA1 output for raster-based maps will be added soon.

Usage

Basic usage is as follows:

from criticalmaas.ta1_geopackage import GeopackageDatabase

db = GeopackageDatabase(
  "my_map.gpkg",
  crs="EPSG:4326" # Geographic coordinates (default)
  # crs="CRITICALMAAS:pixel" # Pixel coordinates
)

# Insert types (required for foreign key constraints)
db.write_models([
  db.model.map(id="test", name="test", description="test"),
  db.model.polygon_type(id="test", name="test", description="test"),
])

# Write features
feat = {
    "properties": {
        "id": "test",
        "map_id": "test",
        "type": "test",
        "confidence": None,
        "provenance": None,
    },
    "geometry": {
        "type": "MultiPolygon",
        "coordinates": [[[(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)]]],
    },
}
db.write_features("polygon_feature", [feat])

See the tests and the Macrostrat CLI writer for more examples.

Schema

Schema diagram

Ongoing work

  • Tests with geographic data
  • Helpers for working with multiple projections
  • Example datasets
  • Example script for dumping a Macrostrat map
  • Schema adjustments and improvements (see tracking issue)
  • Make the package available as criticalmass.ta1_geopackage on PyPI.
  • Create example of writing page_extractions with pixel coordinates

Resources

Prior art

  • Fiona: A python library for working with geospatial vector data.
  • GeoPandas: A python library for working with geospatial vector data.
  • GeoAlchemy 2: A python library for interfacing in PostGIS, Spatialite, and GeoPackage.
  • Fudgeo: modern Python package for working with GeoPackages. Duplicates many features of more common packages like fiona and geopandas but provides low-level access to the GeoPackage spec.

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

criticalmaas_ta1_geopackage-0.2.1.tar.gz (12.5 kB view hashes)

Uploaded Source

Built Distribution

criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl (14.9 kB view hashes)

Uploaded Python 3

Supported by

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