naturtag.metadata.meta_metadata module#

class naturtag.metadata.meta_metadata.MetaMetadata(*args, **kwargs)#

Bases: ImageMetadata

Parses observation info and other higher-level details derived from raw image metadata

Example

>>> from naturtag import MetaMetadata
>>> meta = MetaMetadata('/path/to/image.jpg')
>>> print(meta.summary)
>>> print(meta.to_observation())
property combined: dict[str, Any]#
property coordinates: Tuple[float, float] | None#

Get coordinates as decimal degrees from EXIF or XMP metadata

property date: str | None#

Date taken or created, as a string

property filtered_combined: dict[str, Any]#
property has_any_tags: bool#
property has_coordinates: bool#
property has_observation: bool#
property has_taxon: bool#
property inaturalist_ids: tuple[Optional[int], Optional[int]]#

Get taxon and/or observation IDs from metadata if available

merge(other)#

Update metadata from another instance

Return type:

MetaMetadata

property min_rank: tuple[str, str] | None#

Get the lowest (most specific) taxonomic rank and name from tags, if any

Returns:

(rank, name)

property observation_id: int | None#
property observation_url: str#
property simplified: dict[str, str]#

Get simplified/deduplicated key-value pairs from a combination of keywords + basic metadata

property summary: str#

Get a condensed summary of available metadata

property taxon_id: int | None#
property taxon_url: str#
to_observation()#

Convert DwC metadata to an observation object, if possible

Return type:

Observation

update(new_metadata)#

Update arbitrary EXIF, IPTC, and/or XMP metadata, and reset/update derived properties

update_coordinates(coordinates, accuracy=None)#
update_keywords(keywords)#

Update only keyword metadata. Keywords will be written to appropriate tags for each metadata format.

naturtag.metadata.meta_metadata.get_inaturalist_ids(metadata)#

Look for taxon and/or observation IDs from metadata if available

Return type:

tuple[Optional[int], Optional[int]]

naturtag.metadata.meta_metadata.simplify_keys(mapping)#

Simplify/deduplicate dict keys, to reduce variations in similarly-named keys

Example::
>>> simplify_keys({'my_namespace:Sub_Family': 'Panorpinae'})
{'subfamily': 'Panorpinae'}
Return type:

dict[str, str]

Returns:

dict with simplified/deduplicated keys