Table Resource

pydantic model geometamaker.models.TableResource[source]

Class for metadata for a table resource.

Show JSON schema
{
   "title": "TableResource",
   "description": "Class for metadata for a table resource.",
   "type": "object",
   "properties": {
      "contact": {
         "$ref": "#/$defs/ContactSchema",
         "description": "Contact information for the data author."
      },
      "license": {
         "$ref": "#/$defs/LicenseSchema",
         "description": "Data license information."
      },
      "metadata_path": {
         "default": "",
         "title": "Metadata Path",
         "type": "string"
      },
      "geometamaker_version": {
         "default": "",
         "description": "The version of geometamaker used to create this metadata resource.",
         "title": "Geometamaker Version",
         "type": "string"
      },
      "bytes": {
         "default": 0,
         "description": "File size of the resource in bytes.",
         "title": "Bytes",
         "type": "integer"
      },
      "format": {
         "default": "",
         "description": "File format of the resource.",
         "title": "Format",
         "type": "string"
      },
      "uid": {
         "default": "",
         "description": "Unique identifier for the resource.",
         "title": "Uid",
         "type": "string"
      },
      "path": {
         "default": "",
         "description": "Path to the resource being described.",
         "title": "Path",
         "type": "string"
      },
      "scheme": {
         "default": "",
         "description": "File protocol for opening the resource.",
         "title": "Scheme",
         "type": "string"
      },
      "type": {
         "default": "",
         "description": "The type of resource being described.",
         "title": "Type",
         "type": "string"
      },
      "last_modified": {
         "default": "",
         "description": "Last modified time of the file at ``path``.",
         "title": "Last Modified",
         "type": "string"
      },
      "citation": {
         "default": "",
         "description": "A citation for the resource.",
         "title": "Citation",
         "type": "string"
      },
      "description": {
         "default": "",
         "description": "A text description of the resource.",
         "title": "Description",
         "type": "string"
      },
      "doi": {
         "default": "",
         "description": "A digital object identifier for the resource.",
         "title": "Doi",
         "type": "string"
      },
      "edition": {
         "default": "",
         "description": "A string representing the edition, or version, of the resource.",
         "title": "Edition",
         "type": "string"
      },
      "keywords": {
         "description": "A list of keywords that describe the subject-matter of the resource.",
         "items": {
            "type": "string"
         },
         "title": "Keywords",
         "type": "array"
      },
      "lineage": {
         "default": "",
         "description": "A text description of how the resource was created.",
         "title": "Lineage",
         "type": "string"
      },
      "placenames": {
         "description": "A list of geographic places associated with the resource.",
         "items": {
            "type": "string"
         },
         "title": "Placenames",
         "type": "array"
      },
      "purpose": {
         "default": "",
         "description": "The author's stated purpose for the resource.",
         "title": "Purpose",
         "type": "string"
      },
      "title": {
         "default": "",
         "description": "The title of the resource.",
         "title": "Title",
         "type": "string"
      },
      "url": {
         "default": "",
         "description": "A URL where the resource is available.",
         "title": "Url",
         "type": "string"
      },
      "spatial": {
         "anyOf": [
            {
               "$ref": "#/$defs/SpatialSchema"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "An object for describing spatial properties of the resource."
      },
      "encoding": {
         "default": "",
         "description": "File encoding of the resource.",
         "title": "Encoding",
         "type": "string"
      },
      "sources": {
         "description": "A list of files which comprise the dataset or resource.",
         "items": {
            "type": "string"
         },
         "title": "Sources",
         "type": "array"
      },
      "data_model": {
         "$ref": "#/$defs/TableSchema",
         "description": "A ``models.TableSchema`` object for describing fields."
      }
   },
   "$defs": {
      "BoundingBox": {
         "description": "Class for a spatial bounding box.",
         "properties": {
            "xmin": {
               "title": "Xmin",
               "type": "number"
            },
            "ymin": {
               "title": "Ymin",
               "type": "number"
            },
            "xmax": {
               "title": "Xmax",
               "type": "number"
            },
            "ymax": {
               "title": "Ymax",
               "type": "number"
            }
         },
         "required": [
            "xmin",
            "ymin",
            "xmax",
            "ymax"
         ],
         "title": "BoundingBox",
         "type": "object"
      },
      "ContactSchema": {
         "additionalProperties": false,
         "description": "Class for storing contact information of data author.",
         "properties": {
            "email": {
               "default": "",
               "title": "Email",
               "type": "string"
            },
            "organization": {
               "default": "",
               "title": "Organization",
               "type": "string"
            },
            "individual_name": {
               "default": "",
               "title": "Individual Name",
               "type": "string"
            },
            "position_name": {
               "default": "",
               "title": "Position Name",
               "type": "string"
            }
         },
         "title": "ContactSchema",
         "type": "object"
      },
      "FieldSchema": {
         "additionalProperties": false,
         "description": "Metadata for a field in a table.",
         "properties": {
            "name": {
               "description": "The name used to uniquely identify the field.",
               "title": "Name",
               "type": "string"
            },
            "type": {
               "description": "Datatype of the content of the field.\n\nString label of a type inferred by ``pandas.api.types.infer_dtype``",
               "title": "Type",
               "type": "string"
            },
            "description": {
               "default": "",
               "description": "A description of the field.",
               "title": "Description",
               "type": "string"
            },
            "title": {
               "default": "",
               "description": "A human-readable title for the field.",
               "title": "Title",
               "type": "string"
            },
            "units": {
               "default": "",
               "description": "Unit of measurement for values in the field.",
               "title": "Units",
               "type": "string"
            }
         },
         "required": [
            "name",
            "type"
         ],
         "title": "FieldSchema",
         "type": "object"
      },
      "LicenseSchema": {
         "additionalProperties": false,
         "description": "Class for storing data license information.",
         "properties": {
            "path": {
               "default": "",
               "description": "URL that describes the license.",
               "title": "Path",
               "type": "string"
            },
            "title": {
               "default": "",
               "description": "Name of a license, such as one from http://licenses.opendefinition.org/",
               "title": "Title",
               "type": "string"
            }
         },
         "title": "LicenseSchema",
         "type": "object"
      },
      "SpatialSchema": {
         "additionalProperties": false,
         "description": "Class for keeping track of spatial info.",
         "properties": {
            "bounding_box": {
               "$ref": "#/$defs/BoundingBox",
               "description": "Spatial extent [xmin, ymin, xmax, ymax]."
            },
            "crs": {
               "description": "Coordinate Reference System.",
               "title": "Crs",
               "type": "string"
            },
            "crs_units": {
               "description": "Units of measure for coordinates in the CRS.",
               "title": "Crs Units",
               "type": "string"
            }
         },
         "required": [
            "bounding_box",
            "crs",
            "crs_units"
         ],
         "title": "SpatialSchema",
         "type": "object"
      },
      "TableSchema": {
         "additionalProperties": false,
         "description": "Class for metadata for tables.",
         "properties": {
            "fields": {
               "description": "A list of ``FieldSchema`` objects.",
               "items": {
                  "$ref": "#/$defs/FieldSchema"
               },
               "title": "Fields",
               "type": "array"
            },
            "missingValues": {
               "description": "A list of values that represent missing data.",
               "items": {},
               "title": "Missingvalues",
               "type": "array"
            },
            "primaryKey": {
               "description": "A field or list of fields that uniquely identifies each row in the table.",
               "items": {
                  "type": "string"
               },
               "title": "Primarykey",
               "type": "array"
            },
            "foreignKeys": {
               "description": "A field or list of fields that can be used to join another table.\n\nSee https://datapackage.org/standard/table-schema/#foreignKeys",
               "items": {
                  "type": "string"
               },
               "title": "Foreignkeys",
               "type": "array"
            }
         },
         "required": [
            "fields"
         ],
         "title": "TableSchema",
         "type": "object"
      }
   },
   "additionalProperties": false
}

field bytes: int = 0

File size of the resource in bytes.

field citation: str = ''

A citation for the resource.

field contact: ContactSchema [Optional]

Contact information for the data author.

field data_model: TableSchema [Optional]

A models.TableSchema object for describing fields.

field description: str = ''

A text description of the resource.

field doi: str = ''

A digital object identifier for the resource.

field edition: str = ''

A string representing the edition, or version, of the resource.

field encoding: str = ''

File encoding of the resource.

field format: str = ''

File format of the resource.

field geometamaker_version: str = ''

The version of geometamaker used to create this metadata resource.

field keywords: list[str] [Optional]

A list of keywords that describe the subject-matter of the resource.

field last_modified: str = ''

Last modified time of the file at path.

field license: LicenseSchema [Optional]

Data license information.

field lineage: str = ''

A text description of how the resource was created.

field metadata_path: str = ''
field path: str = ''

Path to the resource being described.

field placenames: list[str] [Optional]

A list of geographic places associated with the resource.

field purpose: str = ''

The author’s stated purpose for the resource.

field scheme: str = ''

File protocol for opening the resource.

field sources: list[str] [Optional]

A list of files which comprise the dataset or resource.

field spatial: SpatialSchema | None = None

An object for describing spatial properties of the resource.

field title: str = ''

The title of the resource.

field type: str = ''

The type of resource being described.

field uid: str = ''

Unique identifier for the resource.

field url: str = ''

A URL where the resource is available.

classmethod load(filepath)

Load metadata document from a yaml file.

Parameters:

filepath (str) – path to yaml file

Returns:

instance of the class

Raises:
  • FileNotFoundError if filepath does not exist

  • ValueError if the metadata is found to be incompatible with – geometamaker.

get_citation()

Get the citation for the dataset.

get_contact()

Get metadata from a contact section.

Returns:

ContactSchema

get_description()

Get the description for the dataset.

get_doi()

Get the doi for the dataset.

get_edition()

Get the edition of the dataset.

Returns:

str or None if edition does not exist.

get_field_description(name)[source]

Get the attribute metadata for a field.

Parameters:

name (str) – name and unique identifier of the field

Returns:

FieldSchema

get_keywords()

Get the keywords describing the dataset.

Returns:

list

get_license()

Get license for the dataset.

Returns:

models.LicenseSchema

get_lineage()

Get the lineage statement of the dataset.

Returns:

str

get_placenames()

Get the placenames describing the dataset.

Returns:

list

get_purpose()

Get purpose for the dataset.

Returns:

str

get_title()

Get the title for the dataset.

get_url()

Get the url for the dataset.

replace(other)

Replace attribute values with those from another instance.

Only attributes that exist in self will exist in the returned instance. Only attribute values that are not empty in other will be used to replace values in self.

Parameters:

other (BaseMetadata)

Returns:

an instance of same type as self

Raises:

TypeError if other is not an instance of BaseMetadata.

set_citation(citation)

Add a citation string for the dataset.

Parameters:

citation (str)

set_contact(organization=None, individual_name=None, position_name=None, email=None)

Add a contact section.

Parameters:
  • organization (str) – name of the responsible organization

  • individual_name (str) – name of the responsible person

  • position_name (str) – role or position of the responsible person

  • email (str) – address of the responsible organization or individual

set_description(description)

Add a description for the dataset.

Parameters:

description (str)

set_doi(doi)

Add a doi string for the dataset.

Parameters:

doi (str)

set_edition(edition)

Set the edition for the dataset.

Parameters:

edition (str) – version of the cited resource

set_field_description(name, title=None, description=None, units=None, type=None)[source]

Define metadata for a tabular field.

Parameters:
  • name (str) – name and unique identifier of the field

  • title (str) – title for the field

  • description (str) – description of the field

  • units (str) – unit of measurement for the field’s values

  • type (str) – datatype of values in the field

set_keywords(keywords)

Describe a dataset with a list of keywords.

Parameters:

keywords (list) – sequence of strings

set_license(title=None, path=None)

Add a license for the dataset.

Either or both title and path are required if there is a license. Call with no arguments to remove license info.

Parameters:
  • title (str) – human-readable title of the license

  • path (str) – url for the license

set_lineage(statement)

Set the lineage statement for the dataset.

Parameters:

statement (str) – general explanation describing the lineage or provenance of the dataset

set_placenames(placenames)

Describe the geography of a dataset with a list of placenames.

Parameters:

places (list) – sequence of strings

set_purpose(purpose)

Add a purpose for the dataset.

Parameters:

purpose (str) – description of the purpose of the source dataset

set_spatial(spatial: SpatialSchema)[source]

Set spatial properties of a resource.

set_title(title)

Add a title for the dataset.

Parameters:

title (str)

set_url(url)

Add a url for the dataset.

Parameters:

url (str)

write(workspace=None, backup=True)

Write metadata yaml to disk.

This creates sidecar files with ‘.yml’ appended to the full filename of the data source. For example,

  • ‘myraster.tif’

  • ‘myraster.tif.yml’

For a CollectionResource, the name of the target YML document can be specified with the target_filename argument of describe_collection.

Parameters:
  • workspace (str) – if None, files write to the same location as the source data. If not None, a path to a local directory to write the file. Use this option if the source data is not on the local filesystem.

  • backup (bool) – whether to write a backup of a pre-existing metadata file before ovewriting it in cases where that file is not a valid geometamaker document.