Base annotation object definitions (sarpy.annotation.base)¶
Base annotation types for general use - based on the geojson implementation
- class sarpy.annotation.base.GeometryProperties(uid=None, name=None, color=None)¶
Bases:
Jsonable
- property uid¶
A unique identifier for the associated geometry element
- Type:
str
- property name¶
The name
- Type:
Optional[str]
- property color¶
The color
- Type:
Optional[str]
- classmethod from_dict(the_json)¶
Deserialize from json.
- Parameters:
the_json (Dict) –
- Return type:
- to_dict(parent_dict=None)¶
Serialize to json.
- Parameters:
parent_dict (None|Dict) –
- Return type:
Dict
- copy()¶
Make a deep copy of the item.
- replicate()¶
Make a replica of the item, where uid has not been copied.
- property type¶
The type identifier.
- Return type:
str
- class sarpy.annotation.base.AnnotationProperties(name=None, description=None, directory=None, geometry_properties=None, parameters=None)¶
Bases:
Jsonable
The basic common properties for an annotation
- property name¶
The name
- Type:
Optional[str]
- property description¶
The description
- Type:
Optional[str]
- property directory¶
The directory - for basic display and/or subdivision purposes
- Type:
Optional[str]
- property geometry_properties: List[GeometryProperties]¶
The geometry properties.
- Type:
List[GeometryProperties]
- add_geometry_property(entry)¶
Add a geometry property to the list.
Warning
Care should be taken that this list stay in sync with the parent geometry.
- Parameters:
entry (Dict|GeometryProperties) – The geometry properties instance of serialized version of it.
- get_geometry_property(item)¶
Fetches the appropriate geometry property.
- Parameters:
item (int|str) – The geometry properties uid or integer index.
- Return type:
- Raises:
KeyError –
- get_geometry_property_and_index(item)¶
Fetches the appropriate geometry property and its integer index.
- Parameters:
item (int|str) – The geometry properties uid or integer index.
- Return type:
(GeometryProperties, int)
- Raises:
KeyError –
- classmethod from_dict(the_json)¶
Deserialize from json.
- Parameters:
the_json (Dict) –
- Return type:
- to_dict(parent_dict=None)¶
Serialize to json.
- Parameters:
parent_dict (None|Dict) –
- Return type:
Dict
- replicate()¶
Make a replica of the item, where uid has not been copied.
- copy()¶
Make a deep copy of the item.
- property type¶
The type identifier.
- Return type:
str
- class sarpy.annotation.base.AnnotationFeature(uid=None, geometry=None, properties=None)¶
Bases:
Feature
An extension of the Feature class which has the properties attribute populated with AnnotationProperties instance.
- property properties¶
The properties.
- Return type:
None|AnnotationProperties
- get_name()¶
Gets a useful name.
- Return type:
str
- property geometry¶
The geometry object.
- Return type:
- property geometry_count¶
The number of base geometry elements
- Type:
int
- get_geometry_name(item)¶
Gets the name, or a reasonable default, for the geometry.
- Parameters:
item (int|str) –
- Return type:
str
- get_geometry_property(item)¶
Gets the geometry properties object for the given index/uid.
- Parameters:
item (int|str) – The geometry properties uid or integer index.
- Return type:
- Raises:
KeyError –
- get_geometry_property_and_index(item)¶
Gets the geometry properties object and integer index for the given index/uid.
- Parameters:
item (int|str) – The geometry properties uid or integer index.
- Return type:
(GeometryProperties, int)
- Raises:
KeyError –
- get_geometry_and_geometry_properties(item)¶
Gets the geometry and geometry properties object for the given index/uid.
- Parameters:
item (int|str) – The geometry properties uid or integer index.
- Return type:
(Point|Line|Polygon, GeometryProperties)
- Raises:
KeyError –
- get_geometry_element(item)¶
Gets the basic geometry object at the given index.
- add_geometry_element(geometry, properties=None)¶
Adds the given geometry to the feature geometry (collection).
- Parameters:
geometry (GeometryObject) –
properties (None|GeometryProperties) –
- remove_geometry_element(item)¶
Remove the geometry element at the given index
- Parameters:
item (int|str) –
- add_to_kml(doc, coord_transform, parent=None)¶
Add this feature to the kml document. Note that coordinates or transformed coordinates are assumed to be WGS-84 coordinates in longitude, latitude order. Currently only the first two (i.e. longitude and latitude) are used in this export.
- Parameters:
doc (sarpy.io.kml.Document) –
coord_transform (None|callable) – If callable, the the transform will be applied to the coordinates before adding to the document.
parent (None|minidom.Element) – The parent node.
- Return type:
None
- copy()¶
Make a deep copy of the item.
- classmethod from_dict(the_json)¶
Deserialize from json.
- Parameters:
the_json (Dict) –
- replicate()¶
Make a replica of the item, where uid has not been copied.
- to_dict(parent_dict=None)¶
Serialize to json.
- Parameters:
parent_dict (None|Dict) –
- Return type:
Dict
- property type¶
The type identifier.
- Return type:
str
- property uid¶
The feature unique identifier.
- Return type:
str
- class sarpy.annotation.base.AnnotationCollection(features=None)¶
Bases:
FeatureCollection
An extension of the FeatureCollection class which has the features are AnnotationFeature instances.
- property features¶
The features list.
- Return type:
List[AnnotationFeature]
- add_feature(feature)¶
Add an annotation.
- Parameters:
feature (AnnotationFeature|Dict) –
- copy()¶
Make a deep copy of the item.
- export_to_kml(file_name, coord_transform=None, **params)¶
Export to a kml document. Note that underlying geometry coordinates or transformed coordinates are assumed in longitude, latitude order. Currently only the first two (i.e. longitude and latitude) are used in this export.
- Parameters:
file_name (str|zipfile.ZipFile|file like) –
coord_transform (None|callable) – The coordinate transform function.
params (dict) –
- Return type:
None
- classmethod from_dict(the_json)¶
Deserialize from json.
- Parameters:
the_json (Dict) –
- get_integer_index(feature_id)¶
Gets the integer index for the given feature id.
- Parameters:
feature_id (str) –
- Return type:
int
- replicate()¶
Make a replica of the item, where uid has not been copied.
- to_dict(parent_dict=None)¶
Serialize to json.
- Parameters:
parent_dict (None|Dict) –
- Return type:
Dict
- property type¶
The type identifier.
- Return type:
str
- class sarpy.annotation.base.FileAnnotationCollection(version=None, annotations=None, image_file_name=None, image_id=None, core_name=None)¶
Bases:
Jsonable
An collection of annotation elements associated with a given single image element file.
- copy()¶
Make a deep copy of the item.
- replicate()¶
Make a replica of the item, where uid has not been copied.
- property type¶
The type identifier.
- Return type:
str
- property version¶
The version
- Type:
str
- property image_file_name¶
The image file name, if appropriate.
- Return type:
None|str
- property image_id¶
The image id, if appropriate.
- Return type:
None|str
- property core_name¶
The image core name, if appropriate.
- Return type:
None|str
- property annotations¶
The annotations.
- Return type:
- add_annotation(annotation)¶
Add an annotation.
- Parameters:
annotation (AnnotationFeature) – The prospective annotation.
- delete_annotation(annotation_id)¶
Deletes the annotation associated with the given id.
- Parameters:
annotation_id (str) –
- classmethod from_file(file_name)¶
Read from (json) file.
- Parameters:
file_name (str) –
- Return type:
- classmethod from_dict(the_dict)¶
Define from a dictionary representation.
- Parameters:
the_dict (dict) –
- Return type:
- to_dict(parent_dict=None)¶
Serialize to json.
- Parameters:
parent_dict (None|Dict) –
- Return type:
Dict