• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language Jinja
  • License
    Other
  • Created over 9 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pygeometa is a Python package to generate metadata for geospatial datasets

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

pygeometa

pygeometa is a Python package to generate 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
python3 setup.py build
python3 setup.py 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

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

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 -r requirements-dev.txt

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 ABS 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

# via setuptools
python3 setup.py test
# manually
cd tests
python3 run_tests.py

Releasing

# update version
vi pygeometa/__init__.py
vi debian/changelog  # add changelog entry and summary of updates
git commit -m 'update release version' pygeometa/__init__.py 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 setup.py sdist bdist_wheel --universal
twine upload dist/*

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

Contact

More Repositories

1

pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
Python
499
star
2

OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
Python
387
star
3

pycsw

pycsw is an OGC CSW server implementation written in Python. pycsw fully implements the OpenGIS Catalogue Service Implementation Specification [Catalogue Service for the Web]. Initial development started in 2010 (more formally announced in 2011). The project is certified OGC Compliant, and is an OGC Reference Implementation. pycsw allows for the publishing and discovery of geospatial metadata via numerous APIs (CSW 2/CSW 3, OpenSearch, OAI-PMH, SRU). Existing repositories of geospatial metadata can also be exposed, providing a standards-based metadata and catalogue component of spatial data infrastructures. pycsw is Open Source, released under an MIT license, and runs on all major platforms (Windows, Linux, Mac OS X). Please read the docs at https://pycsw.org/docs for more information.
Python
206
star
4

pywps

PyWPS is an implementation of the Web Processing Service standard from the Open Geospatial Consortium. PyWPS is written in Python.
Python
176
star
5

stetl

Stetl, Streaming ETL, is a lightweight geospatial processing and ETL framework written in Python.
Python
85
star
6

GeoHealthCheck

Service Status and QoS Checker for OGC Web Services
Python
84
star
7

pygeofilter

pygeofilter is a pure Python parser implementation of OGC filtering standards
Python
82
star
8

mapslicer

MapSlicer is a graphical application for online map publishing.
Python
43
star
9

CadTools

Some tools to perform cad like functions in QGIS.
Python
21
star
10

pywps-flask

Demo service for PyWPS 4 with Flask
Python
21
star
11

diving-into-pygeoapi

pygeoapi is an OGC Reference Implementation supporting numerous OGC API specifications. This workshop will cover publishing geospatial data to the Web using pygeoapi in support of the suite of OGC API standards.
Jupyter Notebook
20
star
12

pygml

Python
14
star
13

pycql

A pure python CQL parser.
Python
11
star
14

GeoUsage

Metrics Analysis for OGC Web Services
Python
10
star
15

demo.pygeoapi.io

Demo setup for https://demo.pygeoapi.io
Shell
8
star
16

geopython.github.io

Project pages for geopython
JavaScript
7
star
17

pygeoapi.io

The pygeoapi.io website
HTML
5
star
18

geolinks

Utilities to deal with geospatial links
Python
5
star
19

pyfes

An implementation of OGC FES/ISO1943
Python
4
star
20

pycsw.org

pycsw website
HTML
3
star
21

demo.pycsw.org

docker-compose setup for pycsw OGC Reference Implementation and demo
HTML
3
star
22

pycsw-workshop

pycsw Workshop
Python
2
star
23

demo.pywps.org

demo.pywps.org setup
Python
1
star
24

pygeoapi-examples

Example pygeoapi deployment patterns and configurations
Shell
1
star