Skip to main content

pygeometa is a Python package to generate metadata for meteorological datasets

Project description

Build Status

pygeometa

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

Table of Contents

Overview

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

Features

  • simple configuration: inspired by Python’s ConfigParser

  • extensible: template architecture allows for easy addition of new metadata formats

  • flexible: use as a command-line tool or integrate as a library

Quickstart

Workflow to generate metadata XML: 1. Install pygeometa 2. Create a ‘metadata control file’ .mcf file that contains metadata information 1. Modify the sample.mcf example 2. pygeometa supports nesting MCF files together, allowing providing a single MCF file for common metadata parameters (e.g. common contact information) 3. Refer to the Metadata Control File Reference documentation 3. Run pygeometa for the .mcf file with a specified target metadata schema

Installation

pygeometa is best installed and used within a Python virtualenv.

Requirements

  • Python 2.7 and above. Works with Python 3.

  • Python virtualenv package

Dependencies

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

Installing the Package

virtualenv my-env
cd my-env
. bin/activate
git clone https://github.com/geopython/pygeometa.git
cd pygeometa
pip install -r requirements.txt
python setup.py build
python setup.py install

Running

From the command line

generate_metadata.py --mcf=path/to/file.mcf --schema=iso19139  # to stdout
generate_metadata.py --mcf=path/to/file.mcf --schema=iso19139 > some_file.xml  # to file
# to use your own defined schema:
generate_metadata.py --mcf=path/to/file.mcf --schema_local=/path/to/my-schema > some_file.xml  # to file

Supported schemas

Schemas supported by pygeometa: * iso19139, reference * iso19139-hnap, reference * Local schema, specified with --schema_local=/path/to/my-schema

Using the API from Python

from pygeometa import render_template
# default schema
xml_string = render_template('/path/to/file.mcf', schema='iso19139')
# user-defined schema
xml_string = render_template('/path/to/file.mcf', schema_local='/path/to/new-schema')
with open('output.xml', 'w') as ff:
    ff.write(xml_string)

Development

Setting up a Development Environment

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

pip install -r requirements-dev.txt

Adding Another Metadata Schema to the Core

List of supported metadata schemas in pygeometa/templates/

To add support to new metadata schemas:

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

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

Running Tests

# via distutils
python setup.py test
# manually
cd tests
python run_tests.py

Code Conventions

Bugs and Issues

All bugs, enhancements and issues can be logged on SSC GitLab at https://github.com/geopython/pygeometa/issues

To do

  • Validation of MCF files (e.g. missing non-optional values, duplicate base_mcf, etc)

  • Consider using reveal.js to provide a generic presentation of pygeometa along with the code

  • Consider using Jekyll or Sphinx to provide pygeometa documentation

History

pygeometa originated within the pygdm project, which provided generic geospatial data management functions. pygdm (now at end of life) was used for generating MSC/CMC geospatial metadata. pygeometa was pulled out of pygdm to focus on the core requirement of generating geospatial metadata within a real-time environment.

In 2015 pygeometa was made publically available in support of the Treasury Board Policy on Acceptable Network and Device Use.

Contact

Project details


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