Skip to main content

Build Status Join the chat at https://matrix.to/#/#geopython_pygeometa:gitter.im Docker

pygeometa

pygeometa is a Python package to manage metadata for geospatial datasets.

Installation

pygeometa is best installed and used within a Python virtualenv.

Requirements

Dependencies

Dependencies are listed in requirements.txt. Dependencies are automatically installed during pygeometa's installation.

Installing the Package

python3 -m venv my-env
cd my-env
. bin/activate
git clone https://github.com/geopython/pygeometa.git
cd pygeometa
pip3 install .

Running

From the command line

# show all subcommands
pygeometa

# show all supported schemas
pygeometa metadata schemas

# provide a basic sanity check/report on an MCF
pygeometa metadata info path/to/file.yml

# generate an ISO 19139 document to stdout
pygeometa metadata generate path/to/file.yml --schema=iso19139

# generate an ISO 19139 document to disk
pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml

# generate an ISO 19139 document to disk with debugging (ERROR, WARNING, INFO, DEBUG)
pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml --verbosity=DEBUG # add verbose (ERROR, WARNING, INFO, DEBUG)

# use your own defined schema
pygeometa metadata generate path/to/file.yml --schema_local=/path/to/my-schema --output=some_file.xml  # to file

# validate your MCF
pygeometa metadata validate path/to/file.yml

# import a metadata document to MCF
pygeometa metadata import path/to/file.xml --schema=iso19139

# import a metadata document to MCF, autodetecting the metadata file format
pygeometa metadata import path/to/file.xml --schema=autodetect  # --schema=autodetect is default

# transform from one metadata representation to another
pygeometa metadata transform path/to/file.xml --input-schema=iso19139 --output-schema=oarec-record

# transform from one metadata representation to another, autodetecting the metadata file format
pygeometa metadata transform path/to/file.xml --input-schema=autodetect --output-schema=oarec-record  # --input-schema=autodetect is default

Docker

pygeometa can also be run as a Docker application:

# run pygeometa via Docker, and map local path /path/to/my-data-dir to /data in Docker
docker run -ti -v /path/to/my-data-dir/:/data/ pygeometa:latest metadata generate --schema oarec-record /data/sample.mcf.yml

Supported schemas

Schemas supported by pygeometa:

Using the API from Python

from pygeometa.core import read_mcf, render_j2_template

# read from disk
mcf_dict = read_mcf('/path/to/file.yml')
# read from string
mcf_dict = read_mcf(mcf_string)

# choose ISO 19139 output schema
from pygeometa.schemas.iso19139 import ISO19139OutputSchema
iso_os = ISO19139OutputSchema()

# default schema
xml_string = iso_os.write(mcf_dict)

# user-defined schema
xml_string = render_j2_template(mcf_dict, template_dir='/path/to/new-schema')

# write to disk
with open('output.xml', 'wb') as ff:
    ff.write(xml_string)

Development

Setting up a Development Environment

Same as installing a package. Use a virtualenv. Also install developer requirements:

pip3 install ".[dev]"

Adding a Metadata Schema to the Core

Adding an output metadata schemas to pygeometa involves extending pygeometa.schemas.base.BaseOutputSchema and supporting the write function to return a string of exported metadata content. If you are using Jinja2 templates, see the next section. If you are using another means of generating metadata (lxml, xml.etree, json, etc.), override the ABC write class to emit a string using your tooling/workflow accordingly. See the below sections for examples.

Once you have added your metadata schema, you need to register it with pygeometa's schema registry:

vi pygeometa/schemas/__init__.py
# edit the SCHEMAS dict with the metadata schema name and dotted path of class

Jinja2 templates

To add support for a new metadata schema using Jinja2 templates:

cp -r pygeometa/schemas/iso19139 pygeometa/schemas/new-schema

Then modify *.j2 files in the new pygeometa/schemas/new-schema directory to comply to new metadata schema.

Custom tooling

To add support for a new metadata schemas using other tooling/workflow:

mkdir pygeometa/schemas/foo
cp pygeometa/schemas/iso19139/__init__.py pygeometa/schemas/foo
vi pygeometa/schemas/foo/__init__.py
# update class name and super().__init__() function accordingly 

Running Tests

cd tests
python3 run_tests.py

Releasing

# update version
vi pyproject.toml  # update [project]/version
vi debian/changelog  # add changelog entry and summary of updates
git commit -m 'update release version' pyproject.toml debian/changelog
# push changes
git push origin master
git tag -a x.y.z -m 'tagging release x.y.z'
# push tag
git push --tags
rm -fr build dist *.egg-info
python3 -m build
twine upload dist/*

# publish release on GitHub (https://github.com/geopython/pygeometa/releases/new)

# bump version back to dev
vi pyproject.toml  # update [project]/version
git push origin master

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

Contact

Release files for pygeometa 0.21.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygeometa 0.21.1
File Size Uploaded
pygeometa-0.21.1.tar.gz 120.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygeometa 0.21.1
File Interpreter ABI Platform
pygeometa-0.21.1-py3-none-any.whl Python 3 none any Details

Total release size: 275.5 kB

Release files / pygeometa-0.21.1.tar.gz

Download URL pygeometa-0.21.1.tar.gz
Size 120.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7ea07aca549c2ec132d078e3960c0f1a27549ae0d51fd7d74f1f9f5e012dfbfe
BLAKE2b-256 checksum
How to use checksums
4dea2b442efc696d3ec57405c8a3a6cb2d063dd2ca7cb74863d2c38d48bf45b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / pygeometa-0.21.1-py3-none-any.whl

Download URL pygeometa-0.21.1-py3-none-any.whl
Size 155.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92369767aa1097ec6182453b00232ce03063fe7813f891aa5a0c837766761563
BLAKE2b-256 checksum
How to use checksums
80114d7acef79d3a72cbb2a445021341a3e62fb400a61777ef2352eac836ecba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.21.1 This release

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.16.0

1 release file

0.15.3

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.3.0

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

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