pygeometa


Namepygeometa JSON
Version 0.16.1 PyPI version JSON
download
home_pagehttps://geopython.github.io/pygeometa
Summarypygeometa is a Python package to generate metadata for geospatial datasets
upload_time2024-08-27 01:58:17
maintainerMeteorological Service of Canada
docs_urlNone
authorMeteorological Service of Canada
requires_pythonNone
licenseMIT
keywords geospatial metadata catalogue discovery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/geopython/pygeometa/workflows/build%20%E2%9A%99%EF%B8%8F/badge.svg)](https://github.com/geopython/pygeometa/actions)
[![Join the chat at https://matrix.to/#/#geopython_pygeometa:gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#geopython_pygeometa:gitter.im)

# pygeometa

[pygeometa](https://geopython.github.io/pygeometa) is a Python package to
generate metadata for geospatial datasets.

## Installation

pygeometa is best installed and used within a Python virtualenv.

### Requirements

* Python 3 and above
* Python [virtualenv](https://virtualenv.pypa.io/) package

### Dependencies

Dependencies are listed in [requirements.txt](requirements.txt). Dependencies
are automatically installed during pygeometa's installation.

### Installing the Package

```bash
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

```bash
# 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:
* dcat, [reference](https://www.w3.org/TR/vocab-dcat-2/)
* iso19139, [reference](http://www.iso.org/iso/catalogue_detail.htm?csnumber=32557)
* iso19139-hnap, [reference](http://www.gcpedia.gc.ca/wiki/Federal_Geospatial_Platform/Policies_and_Standards/Catalogue/Release/Appendix_B_Guidelines_and_Best_Practices/Guide_to_Harmonized_ISO_19115:2003_NAP)
* OGC API - Records - Part 1: Core, record model, [reference](https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/record.yaml)
* SpatioTemporal Asset Catalog [(STAC)](https://stacspec.org)
* iso19139-2, [reference](https://www.iso.org/standard/67039.html)
* [wmo-cmp](doc/content/reference/formats/wmo-cmp.md), [reference](http://wis.wmo.int/2013/metadata/version_1-3-0/WMO_Core_Metadata_Profile_v1.3_Part_1.pdf)
* [wmo-wcmp2](doc/content/reference/formats/wmo-wcmp2.md), [reference](https://wmo-im.github.io/wcmp2)
* [wmo-wigos](doc/content/reference/formats/wmo-wigos.md), [reference](https://library.wmo.int/opac/doc_num.php?explnum_id=3653)
* Local schema, specified with ```--schema_local=/path/to/my-schema```

### Using the API from Python

```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:

```bash
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:

```bash
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:
```bash
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:
```bash
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

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

## Releasing

```bash
# 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

* [PEP8](https://www.python.org/dev/peps/pep-0008)

### Bugs and Issues

All bugs, enhancements and issues are managed on [GitHub](https://github.com/geopython/pygeometa/issues).

## Contact

* [Tom Kralidis](https://github.com/tomkralidis)
* [Alexandre Leroux](https://github.com/alexandreleroux)

            

Raw data

            {
    "_id": null,
    "home_page": "https://geopython.github.io/pygeometa",
    "name": "pygeometa",
    "maintainer": "Meteorological Service of Canada",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "tom.kralidis@canada.ca",
    "keywords": "geospatial metadata catalogue discovery",
    "author": "Meteorological Service of Canada",
    "author_email": "tom.kralidis@canada.ca",
    "download_url": "https://files.pythonhosted.org/packages/e5/ad/523c29ab00c805f49d15f3eea93797e5872c31fe44b2ab591f85acb16853/pygeometa-0.16.1.tar.gz",
    "platform": "all",
    "description": "[![Build Status](https://github.com/geopython/pygeometa/workflows/build%20%E2%9A%99%EF%B8%8F/badge.svg)](https://github.com/geopython/pygeometa/actions)\n[![Join the chat at https://matrix.to/#/#geopython_pygeometa:gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#geopython_pygeometa:gitter.im)\n\n# pygeometa\n\n[pygeometa](https://geopython.github.io/pygeometa) is a Python package to\ngenerate metadata for geospatial datasets.\n\n## Installation\n\npygeometa is best installed and used within a Python virtualenv.\n\n### Requirements\n\n* Python 3 and above\n* Python [virtualenv](https://virtualenv.pypa.io/) package\n\n### Dependencies\n\nDependencies are listed in [requirements.txt](requirements.txt). Dependencies\nare automatically installed during pygeometa's installation.\n\n### Installing the Package\n\n```bash\npython3 -m venv my-env\ncd my-env\n. bin/activate\ngit clone https://github.com/geopython/pygeometa.git\ncd pygeometa\npython3 setup.py build\npython3 setup.py install\n```\n\n## Running\n\n### From the command line\n\n```bash\n# show all subcommands\npygeometa\n\n# show all supported schemas\npygeometa metadata schemas\n\n# provide a basic sanity check/report on an MCF\npygeometa metadata info path/to/file.yml\n\n# generate an ISO 19139 document to stdout\npygeometa metadata generate path/to/file.yml --schema=iso19139\n\n# generate an ISO 19139 document to disk\npygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml\n\n# generate an ISO 19139 document to disk with debugging (ERROR, WARNING, INFO, DEBUG)\npygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml --verbosity=DEBUG # add verbose (ERROR, WARNING, INFO, DEBUG)\n\n# use your own defined schema\npygeometa metadata generate path/to/file.yml --schema_local=/path/to/my-schema --output=some_file.xml  # to file\n\n# validate your MCF\npygeometa metadata validate path/to/file.yml\n\n# import a metadata document to MCF\npygeometa metadata import path/to/file.xml --schema=iso19139\n\n# transform from one metadata representation to another\npygeometa metadata transform path/to/file.xml --input-schema=iso19139 --output-schema=oarec-record\n```\n\n### Supported schemas\nSchemas supported by pygeometa:\n* dcat, [reference](https://www.w3.org/TR/vocab-dcat-2/)\n* iso19139, [reference](http://www.iso.org/iso/catalogue_detail.htm?csnumber=32557)\n* iso19139-hnap, [reference](http://www.gcpedia.gc.ca/wiki/Federal_Geospatial_Platform/Policies_and_Standards/Catalogue/Release/Appendix_B_Guidelines_and_Best_Practices/Guide_to_Harmonized_ISO_19115:2003_NAP)\n* OGC API - Records - Part 1: Core, record model, [reference](https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/record.yaml)\n* SpatioTemporal Asset Catalog [(STAC)](https://stacspec.org)\n* iso19139-2, [reference](https://www.iso.org/standard/67039.html)\n* [wmo-cmp](doc/content/reference/formats/wmo-cmp.md), [reference](http://wis.wmo.int/2013/metadata/version_1-3-0/WMO_Core_Metadata_Profile_v1.3_Part_1.pdf)\n* [wmo-wcmp2](doc/content/reference/formats/wmo-wcmp2.md), [reference](https://wmo-im.github.io/wcmp2)\n* [wmo-wigos](doc/content/reference/formats/wmo-wigos.md), [reference](https://library.wmo.int/opac/doc_num.php?explnum_id=3653)\n* Local schema, specified with ```--schema_local=/path/to/my-schema```\n\n### Using the API from Python\n\n```python\nfrom pygeometa.core import read_mcf, render_j2_template\n\n# read from disk\nmcf_dict = read_mcf('/path/to/file.yml')\n# read from string\nmcf_dict = read_mcf(mcf_string)\n\n# choose ISO 19139 output schema\nfrom pygeometa.schemas.iso19139 import ISO19139OutputSchema\niso_os = ISO19139OutputSchema()\n\n# default schema\nxml_string = iso_os.write(mcf_dict)\n\n# user-defined schema\nxml_string = render_j2_template(mcf_dict, template_dir='/path/to/new-schema')\n\n# write to disk\nwith open('output.xml', 'wb') as ff:\n    ff.write(xml_string)\n```\n\n## Development\n\n### Setting up a Development Environment\n\nSame as installing a package.  Use a virtualenv.  Also install developer\nrequirements:\n\n```bash\npip3 install -r requirements-dev.txt\n```\n\n### Adding a Metadata Schema to the Core\n\nAdding an output metadata schemas to pygeometa involves extending\n`pygeometa.schemas.base.BaseOutputSchema` and supporting the `write`\nfunction to return a string of exported metadata content.  If you are using\nJinja2 templates, see the next section.  If you are using another means of\ngenerating metadata (lxml, xml.etree, json, etc.), override the ABS `write`\nclass to emit a string using your tooling/workflow accordingly.  See the\nbelow sections for examples.\n\nOnce you have added your metadata schema, you need to register it with\npygeometa's schema registry:\n\n```bash\nvi pygeometa/schemas/__init__.py\n# edit the SCHEMAS dict with the metadata schema name and dotted path of class\n```\n\n#### Jinja2 templates\n\nTo add support for a new metadata schema using Jinja2 templates:\n```bash\ncp -r pygeometa/schemas/iso19139 pygeometa/schemas/new-schema\n```\nThen modify `*.j2` files in the new `pygeometa/schemas/new-schema` directory\nto comply to new metadata schema.\n\n#### Custom tooling\n\nTo add support for a new metadata schemas using other tooling/workflow:\n```bash\nmkdir pygeometa/schemas/foo\ncp pygeometa/schemas/iso19139/__init__.py pygeometa/schemas/foo\nvi pygeometa/schemas/foo/__init__.py\n# update class name and super().__init__() function accordingly \n```\n\n### Running Tests\n\n```bash\n# via setuptools\npython3 setup.py test\n# manually\ncd tests\npython3 run_tests.py\n```\n\n## Releasing\n\n```bash\n# update version\nvi pygeometa/__init__.py\nvi debian/changelog  # add changelog entry and summary of updates\ngit commit -m 'update release version' pygeometa/__init__.py debian/changelog\n# push changes\ngit push origin master\ngit tag -a x.y.z -m 'tagging release x.y.z'\n# push tag\ngit push --tags\nrm -fr build dist *.egg-info\npython3 setup.py sdist bdist_wheel --universal\ntwine upload dist/*\n```\n\n### Code Conventions\n\n* [PEP8](https://www.python.org/dev/peps/pep-0008)\n\n### Bugs and Issues\n\nAll bugs, enhancements and issues are managed on [GitHub](https://github.com/geopython/pygeometa/issues).\n\n## Contact\n\n* [Tom Kralidis](https://github.com/tomkralidis)\n* [Alexandre Leroux](https://github.com/alexandreleroux)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "pygeometa is a Python package to generate metadata for geospatial datasets",
    "version": "0.16.1",
    "project_urls": {
        "Homepage": "https://geopython.github.io/pygeometa"
    },
    "split_keywords": [
        "geospatial",
        "metadata",
        "catalogue",
        "discovery"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a69bc31373196e4b939d53503f48dc4df38cdd2b12ffd8f6524589f0498e9061",
                "md5": "b433215ba1acd36b25c53fac716da103",
                "sha256": "c70c4ad47fa1a58ab8310c5b7522e289bb8914151fa4421ae71964dc7738b67c"
            },
            "downloads": -1,
            "filename": "pygeometa-0.16.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b433215ba1acd36b25c53fac716da103",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 79642,
            "upload_time": "2024-08-27T01:58:16",
            "upload_time_iso_8601": "2024-08-27T01:58:16.035531Z",
            "url": "https://files.pythonhosted.org/packages/a6/9b/c31373196e4b939d53503f48dc4df38cdd2b12ffd8f6524589f0498e9061/pygeometa-0.16.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5ad523c29ab00c805f49d15f3eea93797e5872c31fe44b2ab591f85acb16853",
                "md5": "1b08bf540d3ad8314653af41f01c6a24",
                "sha256": "07b333705286226922a916be93a14164e832a460f6a87ada0909cf0f560f4152"
            },
            "downloads": -1,
            "filename": "pygeometa-0.16.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1b08bf540d3ad8314653af41f01c6a24",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 59905,
            "upload_time": "2024-08-27T01:58:17",
            "upload_time_iso_8601": "2024-08-27T01:58:17.906934Z",
            "url": "https://files.pythonhosted.org/packages/e5/ad/523c29ab00c805f49d15f3eea93797e5872c31fe44b2ab591f85acb16853/pygeometa-0.16.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-27 01:58:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pygeometa"
}
        
Elapsed time: 0.39693s