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):
bc_kananaskis.gpkg: Kananaskis Lakes, BC/AB, 1.5 MBgrandcanyon.gpkg: Grand Canyon, AZ, 11.7 MB
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
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_geopackageon 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
fionaandgeopandasbut provides low-level access to the GeoPackage spec.
Metadata
Release files for criticalmaas.ta1-geopackage 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| criticalmaas_ta1_geopackage-0.2.1.tar.gz | 12.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.4 kB
Release files / criticalmaas_ta1_geopackage-0.2.1.tar.gz
| Download URL | criticalmaas_ta1_geopackage-0.2.1.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67f1057f54ad4c444c3cf8d4aab58adca76b256ed023a949ee0de0241d84ef9b
|
|
BLAKE2b-256 checksum How to use checksums |
9f74945163725bb274618acf516dce316d4ee8755730bd8f7ce34bdf7d932ed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Darwin/23.2.0
|
Release files / criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl
| Download URL | criticalmaas_ta1_geopackage-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf7be373087d34b8be145e6b778b03047d7437adc9019847280e490ea42c289f
|
|
BLAKE2b-256 checksum How to use checksums |
863c03f54759db26617eb73d747493356c51be2653b3b24f36c7123ab2da05b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Darwin/23.2.0
|