DictionaryStore¶

class DictionaryStore(*args, **kwargs)[source]¶

Pure python dictionary backed annotation store.

Initialize DictionaryStore.

Methods

append

Insert a new annotation, returning the key.

close

Closes DictionaryStore from file pointer or path.

commit

Commit any in-memory changes to disk.

dump

Serialise a copy of the whole store to a file-like object.

dumps

Serialise and return a copy of store as a string or bytes.

items

Return iterable (generator) over key and annotations.

open

Opens DictionaryStore from file pointer or path.

patch

Patch an annotation at given key.

remove

Remove annotation from the store with its unique key.

Parameters:

connection (Path | str | IO)

append(annotation, key=None)[source]¶

Insert a new annotation, returning the key.

Parameters:
  • annotation (Annotation) – The shapely annotation to insert.

  • key (str) – Optional. The unique key used to identify the annotation in the store. If not given a new UUID4 will be generated and returned instead.

  • self (DictionaryStore)

Returns:

The unique key of the newly inserted annotation.

Return type:

str

close()[source]¶

Closes DictionaryStore from file pointer or path.

Parameters:

self (DictionaryStore)

Return type:

None

commit()[source]¶

Commit any in-memory changes to disk.

Parameters:

self (DictionaryStore)

Return type:

None

dump(fp)[source]¶

Serialise a copy of the whole store to a file-like object.

Parameters:
  • fp (Path or str or IO) – A file path or file handle object for output to disk.

  • self (DictionaryStore)

Return type:

str

dumps()[source]¶

Serialise and return a copy of store as a string or bytes.

Returns:

The serialised store.

Return type:

str or bytes

Parameters:

self (DictionaryStore)

items()[source]¶

Return iterable (generator) over key and annotations.

Parameters:

self (DictionaryStore)

Return type:

Generator[tuple[str, Annotation], None, None]

classmethod open(fp)[source]¶

Opens DictionaryStore from file pointer or path.

Parameters:

fp (Path | str | IO)

Return type:

AnnotationStore

patch(key, geometry=None, properties=None)[source]¶

Patch an annotation at given key.

Partial update of an annotation. Providing only a geometry will update the geometry and leave properties unchanged. Providing a properties dictionary applies a patch operation to the properties. Only updating the properties which are given and leaving the rest unchanged. To completely replace an annotation use __setitem__.

Parameters:
  • key (str) – The key of the annotation to update.

  • geometry (Geometry) – The new geometry. If None, the geometry is not updated.

  • properties (dict) – A dictionary of properties to patch and their new values. If None, the existing properties are not altered.

  • self (DictionaryStore)

Return type:

None

remove(key)[source]¶

Remove annotation from the store with its unique key.

Parameters:
Return type:

None