geometamaker.models module
- pydantic model geometamaker.models.ArchiveResource[source]
Bases:
ResourceClass for metadata for an archive resource.
- field compression: str = ''
The compression method used to create the archive.
- model_post_init(_Resource__context)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- set_spatial(spatial: SpatialSchema)[source]
Set spatial properties of a resource.
- pydantic model geometamaker.models.BandSchema[source]
Bases:
ParentClass for metadata for a raster band.
- field description: str = ''
A description of the band.
- field gdal_metadata: dict = {}
Metadata key:value pairs stored in the GDAL band object.
- field gdal_type: str [Required]
The GDAL data type of the band.
- field index: int [Required]
The index of the band of a GDAL raster, starting at 1.
- field nodata: int | float | None [Required]
The pixel value that represents no data in the band.
- field numpy_type: str [Required]
The numpy data type of the band.
- field raster_attribute_table: RasterAttributeTable | None = None
A representation of a GDAL-readable Raster Attribute Table.
- field title: str = ''
A human-readable title for the band.
- field units: str = ''
Unit of measurement for the pixel values.
- pydantic model geometamaker.models.BaseMetadata[source]
Bases:
ParentA class for the things shared by Resource and Profile.
- field contact: ContactSchema [Optional]
Contact information for the data author.
- field license: LicenseSchema [Optional]
Data license information.
- replace(other)[source]
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_contact(organization=None, individual_name=None, position_name=None, email=None)[source]
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
- pydantic model geometamaker.models.BaseResource[source]
Bases:
BaseMetadataBase class for metadata for a resource.
https://datapackage.org/standard/data-resource/ This class borrows from the Data Package - Resource specification. But we have some additional properties that are important to us.
All attributes are keyword-only so that we can init with default values, allowing the user to get a template with which to complete later.
- field bytes: int = 0
File size of the resource in bytes.
- field citation: str = ''
A citation for the resource.
- 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 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 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 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)[source]
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_edition()[source]
Get the edition of the dataset.
- Returns:
str or
Noneifeditiondoes not exist.
- model_post_init(context: Any, /) None
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- set_description(description)[source]
Add a description for the dataset.
- Parameters:
description (str)
- set_edition(edition)[source]
Set the edition for the dataset.
- Parameters:
edition (str) – version of the cited resource
- set_keywords(keywords)[source]
Describe a dataset with a list of keywords.
- Parameters:
keywords (list) – sequence of strings
- set_lineage(statement)[source]
Set the lineage statement for the dataset.
- Parameters:
statement (str) – general explanation describing the lineage or provenance of the dataset
- set_placenames(placenames)[source]
Describe the geography of a dataset with a list of placenames.
- Parameters:
places (list) – sequence of strings
- set_purpose(purpose)[source]
Add a purpose for the dataset.
- Parameters:
purpose (str) – description of the purpose of the source dataset
- write(workspace=None, backup=True)[source]
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.
- class geometamaker.models.BoundingBox(xmin: float, ymin: float, xmax: float, ymax: float)[source]
Bases:
objectClass for a spatial bounding box.
- xmax: float
- xmin: float
- ymax: float
- ymin: float
- pydantic model geometamaker.models.CollectionItemSchema[source]
Bases:
ParentClass for metadata for collection items.
- field description: str = ''
A text description of the resource.
- field metadata: str = ''
Path to metadata document describing resource
- field path: str = ''
Path to the resource being described.
- pydantic model geometamaker.models.CollectionResource[source]
Bases:
BaseResourceClass for metadata for a collection resource.
In the spatial properties of a collection, the bounding box is the union of the bounding boxes of all the items in the collection. If all items share the same CRS, the collection’s bounding box will match that CRS. If items use a different CRS from each other, bounding boxes are transformed to WGS84 before unioning.
- field items: list[CollectionItemSchema] [Optional]
Files in collection.
- model_post_init(_CollectionResource__context)[source]
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- set_spatial(spatial: SpatialSchema)[source]
Set spatial properties of a resource.
- pydantic model geometamaker.models.ContactSchema[source]
Bases:
ParentClass for storing contact information of data author.
- field email: str = ''
- field individual_name: str = ''
- field organization: str = ''
- field position_name: str = ''
- pydantic model geometamaker.models.FieldSchema[source]
Bases:
ParentMetadata for a field in a table.
- field description: str = ''
A description of the field.
- field name: str [Required]
The name used to uniquely identify the field.
- field title: str = ''
A human-readable title for the field.
- field type: str [Required]
Datatype of the content of the field.
String label of a type inferred by
pandas.api.types.infer_dtype
- field units: str = ''
Unit of measurement for values in the field.
- pydantic model geometamaker.models.LayerSchema[source]
Bases:
ParentClass for metadata for a GDAL vector’s layer.
- field gdal_metadata: dict = {}
Metadata key:value pairs stored in the GDAL layer object.
- field n_features: int [Required]
Number of features in the layer.
- field name: str [Required]
The layer name.
- field table: TableSchema [Optional]
A
models.TableSchemaobject for describing fields in a layer’s table.
- pydantic model geometamaker.models.LicenseSchema[source]
Bases:
ParentClass for storing data license information.
- field path: str = ''
URL that describes the license.
- field title: str = ''
Name of a license, such as one from http://licenses.opendefinition.org/
- pydantic model geometamaker.models.Parent[source]
Bases:
BaseModelParent class on which to configure validation.
Extra attributes are forbidden because we anticipate users editing YML docs manually and this can help catch accidental edits like a typo in an attribute name.
- pydantic model geometamaker.models.Profile[source]
Bases:
BaseMetadataClass for a metadata profile.
A Profile can store metadata properties that are likely to apply to more than one resource, such as
contactandlicense.
- pydantic model geometamaker.models.RATColumnDefn[source]
Bases:
ParentClass for metadata for a column in a raster attribute table.
- field name: str [Required]
The name used to uniquely identify the column.
- field type: str [Required]
Datatype of the content of the column.
String representation of one of
GDALRATFieldTypeorOGRFieldType.
- field usage: str [Required]
The intended use of the column.
String representation of one of
GDALRATFieldUsage.
- pydantic model geometamaker.models.RasterAttributeTable[source]
Bases:
ParentClass for metadata for a raster attribute table.
- field columns: list[RATColumnDefn] [Required]
A list of column definitions in the raster attribute table.
- field rows: list[dict] [Required]
A list of dicts representing rows in the raster attribute table.
- field table_type: Literal['Thematic', 'Athematic', 'Unknown'] [Required]
One of
GDALRATTableTypeor Unknown.
- pydantic model geometamaker.models.RasterResource[source]
Bases:
ResourceClass for metadata for a raster resource.
- field data_model: RasterSchema [Required]
An object for describing raster properties and bands.
- field spatial: SpatialSchema [Required]
An object for describing spatial properties of a GDAL dataset.
- 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_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
- model_post_init(_Resource__context)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- 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
- pydantic model geometamaker.models.RasterSchema[source]
Bases:
ParentClass for metadata for raster bands.
- field bands: list[BandSchema] [Required]
A list of
BandSchemaobjects.
- field gdal_metadata: dict = {}
Metadata key:value pairs stored in the GDAL raster object.
- field pixel_size: tuple[int | float, int | float] [Required]
The width and height of a pixel measured in
SpatialSchema.crs_units.
- field raster_size: dict | list [Required]
The width and height of the raster measured in number of pixels.
- pydantic model geometamaker.models.Resource[source]
Bases:
BaseResourceMetadata class for general-purpose resources.
This class extends BaseResource and provides metadata for a single file or dataset, including encoding and source file references. It serves as a base for more specific resource types (e.g., table, raster, vector, archive) and is typically initialized by describe().
- field encoding: str = ''
File encoding of the resource.
- field sources: list[str] [Optional]
A list of files which comprise the dataset or resource.
- pydantic model geometamaker.models.SpatialSchema[source]
Bases:
ParentClass for keeping track of spatial info.
- field bounding_box: BoundingBox [Required]
Spatial extent [xmin, ymin, xmax, ymax].
- field crs: str [Required]
Coordinate Reference System.
- field crs_units: str [Required]
Units of measure for coordinates in the CRS.
- pydantic model geometamaker.models.TableResource[source]
Bases:
ResourceClass for metadata for a table resource.
- field data_model: TableSchema [Optional]
A
models.TableSchemaobject for describing fields.
- get_field_description(name)[source]
Get the attribute metadata for a field.
- Parameters:
name (str) – name and unique identifier of the field
- Returns:
FieldSchema
- model_post_init(_Resource__context)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- 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_spatial(spatial: SpatialSchema)[source]
Set spatial properties of a resource.
- pydantic model geometamaker.models.TableSchema[source]
Bases:
ParentClass for metadata for tables.
- field fields: list[FieldSchema] [Required]
A list of
FieldSchemaobjects.
- field foreignKeys: list[str] [Optional]
A field or list of fields that can be used to join another table.
See https://datapackage.org/standard/table-schema/#foreignKeys
- field missingValues: list [Optional]
A list of values that represent missing data.
- field primaryKey: list[str] [Optional]
A field or list of fields that uniquely identifies each row in the table.
- get_field_description(name)[source]
Get the attribute metadata for a field.
- Parameters:
name (str) – name and unique identifier of the field
- Returns:
FieldSchema
- 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
- pydantic model geometamaker.models.VectorResource[source]
Bases:
ResourceClass for metadata for a vector resource.
- field data_model: VectorSchema [Required]
An object for describing vector properties and layers.
- field spatial: SpatialSchema [Required]
An object for describing spatial properties of a GDAL dataset.
- get_field_description(name)[source]
Get the attribute metadata for a field.
- Parameters:
name (str) – name and unique identifier of the field
- Returns:
FieldSchema
- model_post_init(_Resource__context)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- 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