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 details)

Uploaded Source

Built Distribution

File details

Details for the file criticalmaas_ta1_geopackage-0.2.1.tar.gz.

File metadata

File hashes

Hashes for criticalmaas_ta1_geopackage-0.2.1.tar.gz
Algorithm Hash digest
SHA256 67f1057f54ad4c444c3cf8d4aab58adca76b256ed023a949ee0de0241d84ef9b
MD5 83c343ec6a84c84bbf72bdf9857cd2ec
BLAKE2b-256 9f74945163725bb274618acf516dce316d4ee8755730bd8f7ce34bdf7d932ed4

See more details on using hashes here.

File details

Details for the file criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf7be373087d34b8be145e6b778b03047d7437adc9019847280e490ea42c289f
MD5 9914f7d3de4409b09cd171fb7a8fcd7b
BLAKE2b-256 863c03f54759db26617eb73d747493356c51be2653b3b24f36c7123ab2da05b6

See more details on using hashes here.

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