Raster Resource
- pydantic model geometamaker.models.RasterResource[source]
Class for metadata for a raster resource.
Show JSON schema
{ "title": "RasterResource", "description": "Class for metadata for a raster 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": { "$ref": "#/$defs/SpatialSchema", "description": "An object for describing spatial properties of a GDAL dataset." }, "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/RasterSchema", "description": "An object for describing raster properties and bands." } }, "$defs": { "BandSchema": { "additionalProperties": false, "description": "Class for metadata for a raster band.", "properties": { "index": { "description": "The index of the band of a GDAL raster, starting at 1.", "title": "Index", "type": "integer" }, "gdal_type": { "description": "The GDAL data type of the band.", "title": "Gdal Type", "type": "string" }, "numpy_type": { "description": "The numpy data type of the band.", "title": "Numpy Type", "type": "string" }, "nodata": { "anyOf": [ { "type": "integer" }, { "type": "number" }, { "type": "null" } ], "description": "The pixel value that represents no data in the band.", "title": "Nodata" }, "description": { "default": "", "description": "A description of the band.", "title": "Description", "type": "string" }, "title": { "default": "", "description": "A human-readable title for the band.", "title": "Title", "type": "string" }, "units": { "default": "", "description": "Unit of measurement for the pixel values.", "title": "Units", "type": "string" }, "gdal_metadata": { "additionalProperties": true, "default": {}, "description": "Metadata key:value pairs stored in the GDAL band object.", "title": "Gdal Metadata", "type": "object" }, "raster_attribute_table": { "anyOf": [ { "$ref": "#/$defs/RasterAttributeTable" }, { "type": "null" } ], "default": null, "description": "A representation of a GDAL-readable Raster Attribute Table." } }, "required": [ "index", "gdal_type", "numpy_type", "nodata" ], "title": "BandSchema", "type": "object" }, "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" }, "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" }, "RATColumnDefn": { "additionalProperties": false, "description": "Class for metadata for a column in a raster attribute table.", "properties": { "name": { "description": "The name used to uniquely identify the column.", "title": "Name", "type": "string" }, "type": { "description": "Datatype of the content of the column.\n\nString representation of one of ``GDALRATFieldType`` or ``OGRFieldType``.", "title": "Type", "type": "string" }, "usage": { "description": "The intended use of the column.\n\nString representation of one of ``GDALRATFieldUsage``.", "title": "Usage", "type": "string" } }, "required": [ "name", "type", "usage" ], "title": "RATColumnDefn", "type": "object" }, "RasterAttributeTable": { "additionalProperties": false, "description": "Class for metadata for a raster attribute table.", "properties": { "table_type": { "description": "One of ``GDALRATTableType`` or Unknown.", "enum": [ "Thematic", "Athematic", "Unknown" ], "title": "Table Type", "type": "string" }, "columns": { "description": "A list of column definitions in the raster attribute table.", "items": { "$ref": "#/$defs/RATColumnDefn" }, "title": "Columns", "type": "array" }, "rows": { "description": "A list of dicts representing rows in the raster attribute table.", "items": { "additionalProperties": true, "type": "object" }, "title": "Rows", "type": "array" } }, "required": [ "table_type", "columns", "rows" ], "title": "RasterAttributeTable", "type": "object" }, "RasterSchema": { "additionalProperties": false, "description": "Class for metadata for raster bands.", "properties": { "bands": { "description": "A list of ``BandSchema`` objects.", "items": { "$ref": "#/$defs/BandSchema" }, "title": "Bands", "type": "array" }, "pixel_size": { "description": "The width and height of a pixel measured in ``SpatialSchema.crs_units``.", "maxItems": 2, "minItems": 2, "prefixItems": [ { "anyOf": [ { "type": "integer" }, { "type": "number" } ] }, { "anyOf": [ { "type": "integer" }, { "type": "number" } ] } ], "title": "Pixel Size", "type": "array" }, "raster_size": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "items": {}, "type": "array" } ], "description": "The width and height of the raster measured in number of pixels.", "title": "Raster Size" }, "gdal_metadata": { "additionalProperties": true, "default": {}, "description": "Metadata key:value pairs stored in the GDAL raster object.", "title": "Gdal Metadata", "type": "object" } }, "required": [ "bands", "pixel_size", "raster_size" ], "title": "RasterSchema", "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" } }, "additionalProperties": false, "required": [ "spatial", "data_model" ] }
- 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: RasterSchema [Required]
An object for describing raster properties and bands.
- 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 [Required]
An object for describing spatial properties of a GDAL dataset.
- 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_band_description(band_number)[source]
Get the metadata for a band.
- Parameters:
band_number (int) – a raster band index, starting at 1
- Returns:
BandSchema
- 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
Noneifeditiondoes not exist.
- get_keywords()
Get the keywords describing the dataset.
- Returns:
list
- get_license()
Get
licensefor 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
purposefor the dataset.- Returns:
str
- get_rat(band_number)[source]
Get the raster attribute table for a band, if it exists.
- Parameters:
band_number (int) – a raster band index, starting at 1
- Returns:
RasterAttributeTable or None if no RAT exists for the band
- 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
selfwill exist in the returned instance. Only attribute values that are not empty inotherwill be used to replace values inself.- Parameters:
other (BaseMetadata)
- Returns:
an instance of same type as
self- Raises:
TypeError if other is not an instance of BaseMetadata. –
- set_band_description(band_number, title=None, description=None, units=None)[source]
Define metadata for a raster band.
- Parameters:
band_number (int) – a raster band index, starting at 1
title (str) – title for the raster band
description (str) – description of the raster band
units (str) – unit of measurement for the band’s pixel values
- 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_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_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 thetarget_filenameargument ofdescribe_collection.- Parameters:
workspace (str) – if
None, files write to the same location as the source data. If notNone, 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.