### Install pygeometa from source Source: https://geopython.github.io/pygeometa/tutorial Commands to set up a virtual environment and install the package from the GitHub repository. ```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 ``` -------------------------------- ### Install development requirements Source: https://geopython.github.io/pygeometa/tutorial Install additional dependencies required for development. ```bash pip3 install -r requirements-dev.txt ``` -------------------------------- ### Create custom schema tooling Source: https://geopython.github.io/pygeometa/tutorial Setup directory structure for a custom schema implementation. ```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 ``` -------------------------------- ### Install pygeometa via pip Source: https://geopython.github.io/pygeometa/tutorial Use this command to install the latest stable release of pygeometa. Requires Python 3 or greater. ```bash pip3 install pygeometa ``` -------------------------------- ### Use pygeometa API Source: https://geopython.github.io/pygeometa/tutorial Examples for reading MCF files and rendering metadata using specific output schemas. ```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, schema_local='/path/to/new-schema') # write to disk with open('output.xml', 'wb') as ff: ff.write(xml_string) ``` -------------------------------- ### Configure multilingual metadata Source: https://geopython.github.io/pygeometa/reference/mcf Examples of defining primary and alternate languages, and providing multilingual values for fields. ```yaml metadata: language: en language_alternate: fr ``` ```yaml # single language title: foo # single language, explicit title: en: foo # two languages, explicit title: en: foo fr: bar ``` -------------------------------- ### Define identification dates in YAML Source: https://geopython.github.io/pygeometa/reference/mcf Example configuration for specifying creation and publication dates within the identification section. ```yaml identification: ... dates: creation: 2011-11-11 publication: 2000-09-01T00:00:00Z ``` -------------------------------- ### Define metadata dates in MCF Source: https://geopython.github.io/pygeometa/reference/mcf Example of the YAML structure for defining creation and revision dates within the metadata section. ```yaml metadata: ... dates: creation: 2025-03-21 revision: 2026-11-25 ``` -------------------------------- ### Define HNAP distribution sections in MCF Source: https://geopython.github.io/pygeometa/reference/extensions/iso19139-hnap Example of a valid distribution section configuration for HNAP, requiring bilingual names, content types, and formats with specific suffixes. ```yaml distribution: waf_fra-CAN: url: https://dd.weather.gc.ca/model_gem_global/25km/grib2/lat_lon/ type: WWW:LINK name: en: MSC Datamart fr: Datamart du SMC hnap_contenttype: en: Dataset fr: Données format: en: Other fr: Autre format_version: '0' function: download waf_eng-CAN: url: https://dd.weather.gc.ca/model_gem_global/25km/grib2/lat_lon/ type: WWW:LINK name: en: MSC Datamart fr: Datamart du SMC hnap_contenttype: en: Dataset fr: Données format: en: Other fr: Autre format_version: '0' function: download wms_eng-CAN: url: https://geo.weather.gc.ca/geomet/?lang=E&service=WMS&request=GetCapabilities&layers=GDPS.ETA_TT hnap_contenttype: en: Web Service fr: Service Web type: OGC:WMS format: WMS format_version: '1.1.1' name: en: GDPS.ETA_TT fr: GDPS.ETA_TT function: download wms_fra-CAN: url: https://geo.weather.gc.ca/geomet/?lang=E&service=WMS&request=GetCapabilities&layers=GDPS.ETA_TT hnap_contenttype: en: Web Service fr: Service Web type: OGC:WMS format: WMS format_version: '1.1.1' name: en: GDPS.ETA_TT fr: GDPS.ETA_TT function: download ``` -------------------------------- ### Initialize metadata schema plugin Source: https://geopython.github.io/pygeometa/tutorial Required initializer code when extending BaseOutputSchema. ```python # initialize args: super().__init__('shortname', 'my cool metadata', 'xml', THISDIR) # - 'shortname': shortname identifier for metadata schema # - 'my cool metadata': descripts of metadata schema # - 'xml': encoding type (default is `xml`; `json` also supported) # - 'THISDIR': current directory of plugin file for template rendering ``` -------------------------------- ### Release pygeometa package Source: https://geopython.github.io/pygeometa/tutorial Use these commands to build the distribution files and upload them to the package repository. ```bash python3 setup.py sdist bdist_wheel --universal twine upload dist/* ``` -------------------------------- ### Run tests Source: https://geopython.github.io/pygeometa/tutorial Execute the test suite using distutils or the test runner script. ```bash # via distutils python3 setup.py test # manually cd tests python3 run_tests.py ``` -------------------------------- ### Configure pygeoapi processes Source: https://geopython.github.io/pygeometa/pygeoapi-plugin Add these definitions to the pygeoapi configuration file to register the available pygeometa processes. ```yaml pygeometa-metadata-schemas: type: process processor: name: pygeometa.pygeoapi_plugin.PygeometaMetadataSchemasProcessor pygeometa-metadata-import: type: process processor: name: pygeometa.pygeoapi_plugin.PygeometaMetadataImportProcessor pygeometa-metadata-validate: type: process processor: name: pygeometa.pygeoapi_plugin.PygeometaMetadataValidateProcessor pygeometa-metadata-generate: type: process processor: name: pygeometa.pygeoapi_plugin.PygeometaMetadataGenerateProcessor pygeometa-metadata-transform: type: process processor: name: pygeometa.pygeoapi_plugin.PygeometaMetadataTransformProcessor ``` -------------------------------- ### Run pygeometa CLI commands Source: https://geopython.github.io/pygeometa/tutorial A collection of common CLI operations for managing metadata, including generation, validation, and transformation tasks. ```bash # show all subcommands pygeometa # show all supported schemas pygeometa metadata schemas # provide a basic sanity check/report on an MCF (Metadata Control File) 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 an MCF document pygeometa 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 # migrate an MCF document pygeometa metadata migrate path/to/file.mcf.yml # 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 ``` -------------------------------- ### Create new Jinja2 schema Source: https://geopython.github.io/pygeometa/tutorial Copy an existing schema to use as a template for a new one. ```bash cp -r pygeometa/schemas/iso19139 pygeometa/schemas/new-schema ``` -------------------------------- ### Manage file encoding Source: https://geopython.github.io/pygeometa/reference/mcf Commands for checking and converting file encodings to UTF-8 in a Unix-like environment. ```bash # editing in vim # :set encoding=utf8 # pasting in vim # in insert mode, hit CTRL-V $CODE, where $CODE is as per https://www.htmlhelp.com/reference/charset # to see how the file is actually encoded on disk file --mime-encoding file.txt file -i file.txt # to convert from one encoding to another iconv -f iso8859-1 -t utf-8 file.yml > file.yml.new ``` -------------------------------- ### Register metadata schema Source: https://geopython.github.io/pygeometa/tutorial Edit the registry to include the new metadata schema class. ```bash vi pygeometa/schemas/__init__.py # edit the SCHEMAS dict with the metadata schema name and dotted path of class ``` -------------------------------- ### Regenerate pygeoapi OpenAPI configuration Source: https://geopython.github.io/pygeometa/pygeoapi-plugin Run this command to update the OpenAPI specification after modifying the pygeoapi configuration. ```bash pygeoapi openapi generate $PYGEOAPI_CONFIG --output-file $PYGEOAPI_OPENAPI ``` -------------------------------- ### Define MCF distribution sections Source: https://geopython.github.io/pygeometa/reference/mcf Shows the nesting structure for defining multiple distribution methods within an MCF. ```yaml distribution: wms: .... waf: .... ``` -------------------------------- ### Use environment variables in MCF Source: https://geopython.github.io/pygeometa/reference/mcf Syntax for referencing environment variables within an MCF file. ```yaml metadata: identifier: 3f342f64-9348-11df-ba6a-0014c2c00eab parentidentifier: ${COLLECTION_ID} ``` -------------------------------- ### Define content_info attributes Source: https://geopython.github.io/pygeometa/reference/mcf Configure nested attributes for a content_info object, including titles, types, and sample values. ```yaml attributes: - name: temperature title: en: Air temperature abstract: en: Description of air temperature attribute type: number units: K values: [1.2, 2.5, 1.3] ``` -------------------------------- ### Define MCF contact sections Source: https://geopython.github.io/pygeometa/reference/mcf Demonstrates the nesting structure for defining multiple contact roles within an MCF. ```yaml contact: pointOfContact: .... distributor: .... ``` -------------------------------- ### Reuse contact information with YAML anchors Source: https://geopython.github.io/pygeometa/reference/mcf Uses YAML node anchors and references to share identical contact information between different roles. ```yaml contact: pointOfContact: &id_contact_poc ... distributor: *id_contact_poc ``` -------------------------------- ### Define identification keywords in YAML Source: https://geopython.github.io/pygeometa/reference/mcf Configures nested keyword sections including vocabulary definitions and codelist references. ```yaml identification: ... keywords: default: keywords: en: [foo1, bar1] fr: [foo2, bar2] keywords_type: theme vocabulary: name: my vocabulary url: https://example.org/vocab wmo: keywords: en: [foo3, bar3] fr: [foo4, bar4] keywords_type: theme keywords_codelist: https://wis.wmo.int/2011/schemata/iso19139_2007/schema/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode ``` -------------------------------- ### Define identification extents in YAML Source: https://geopython.github.io/pygeometa/reference/mcf Configures spatial bounding boxes and temporal ranges for a dataset. ```yaml identification: ... extents: spatial: - bbox: [-141,42,-52,84] crs: 4326 temporal: - begin: 1950-07-31 end: now resolution: P1D ``` -------------------------------- ### Define attribute codelist values Source: https://geopython.github.io/pygeometa/reference/mcf Define a list of values using a codelist structure with names, titles, and URLs. ```yaml values: codelist: - name: foo title: en: foo title abstract: en: foo description url: https://example.org/values/foo ``` -------------------------------- ### Define attribute range values Source: https://geopython.github.io/pygeometa/reference/mcf Specify a minimum and maximum range for an attribute. ```yaml values: range: [1, 4] ``` -------------------------------- ### Define attribute enum values Source: https://geopython.github.io/pygeometa/reference/mcf Specify an enumerated list of allowed values for an attribute. ```yaml values: enum: [1, 2, 3. 4] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.