Object Attributes🍋
ObjectAttribute
🍋
Bases: Entity
Base class holding elements information/meta-data defining object attributes. It does not hold the attribute data directly but simply points to the database to retrieve it dynamically so that the values are always up-to-date.
An attribute can be either static or dynamic, i-e its value will be recomputed according to the defined expression/condition each time. Therefore it is not valid to have a dynamic attribute without expression.
An ObjectAttribute requires a parent ObjectDB, it is therefore not advised to instantiate any descendant of this class directly. Object attribute creation should be done through the GeoRefObject instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db |
ObjectDB
|
reference ObjectDB to get data from. |
required |
name |
str
|
attribute name. |
required |
expr |
Optional[str]
|
attribute is computed as a condition or expression of other attributes. |
None
|
dynamic |
bool
|
attributes values are recomputed each time the data is requested. expr must be defined if attribute is dynamic. |
False
|
read_only |
bool
|
attribute data is protected. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
name of the attribute. |
expr |
str
|
expression or condition to compute the attribute data. |
dynamic |
bool
|
if True, data is recomputed by ObjectDB each time it is accessed. |
read_only |
bool
|
whether the attribute is considered read-only. |
dynamic: bool
property
writable
🍋
Return whether the attribute is dynamic, i-e. its data is recomputed using the provided expression.
Returns:
Type | Description |
---|---|
bool
|
True if dynamic, False otherwise. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.dynamic
False
expr: str
property
🍋
Return the attribute expression if provided at creation, otherwise None.
Returns:
Type | Description |
---|---|
str
|
Attribute expression. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.set_property_expr('XYZ', 'X * Y * Z', False)
prop_xyz = point_cloud.property("XYZ")
prop_xyz.expr
'X * Y * Z'
name: str
property
🍋
Return the attribute name.
Returns:
Type | Description |
---|---|
str
|
Attribute name. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.name
'X'
read_only: bool
property
writable
🍋
Return whether the attribute is read-only, i-e. its data is protected.
Returns:
Type | Description |
---|---|
bool
|
True if read-only, False otherwise. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.read_only
False
data(region=None)
🍋
Return the data associated to this attribute. If dynamic, the data will be recomputed first according to its provided expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region |
str
|
Region or condition to filter data. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
Underlying attribute data array. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.data()
array([ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27])
ObjectGISRepresentation
🍋
Bases: ObjectDB
Geometrical database for spatially represented objects (see GISObject). This database is specific to handle spatial data (see geopandas.GeoDataFrame) and therefore must be provided when instantiating it.
overlay(other_gis_repr, **kwargs)
🍋
Perform spatial overlay between two ObjectGISRepresentation.
Allowed kwargs are GeoPandas overlay
function arguments.
See GeoPandas - Overlay.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other_gis_repr |
ObjectGISRepresentation
|
ObjectGISRepresentation. |
required |
Returns:
Type | Description |
---|---|
GeoDataFrame
|
New GeoDataFrame. |
plot(interactive_map=False, interactive_max_sample=5000, **kwargs)
🍋
Display the data on a regular plot or an interactive map.
Notes
- interactive map requires
folium
andmapclassify
packages to be installed. - a CRS must be defined for the data to be properly plotted. If the data doesn't have a CRS, the Project CRS will be used by default. See Project.
- interactive map works within a Jupyter Notebook context, please see
folium
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interactive_map |
bool
|
if True, |
False
|
interactive_max_sample |
int
|
maximum number of samples to display in interactive mode. Above 10 000 samples, loading time and interactivity will be impacted. |
5000
|
**kwargs |
extra arguments to pass to GeoPandas - Plot or GeoPandas - Explore. |
{}
|
Returns:
Type | Description |
---|---|
Union[Axes, Map]
|
A folium Map in interactive mode, or an instance of Matplotlib Axes otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
Packages are missing for interactive mode. |
set_crs(crs)
🍋
Set the Coordinate Reference System (CRS) of the GISObject.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
crs |
CRS
|
PyProj CRS. |
required |
ObjectProperty
🍋
Bases: ObjectAttribute
Property attribute class. See ObjectAttribute for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db |
ObjectDB
|
reference ObjectDB to get data from. |
required |
name |
str
|
property name. |
required |
kind |
Optional[PropertyKind]
|
property kind, see PropertyKind enum for more available kind. |
None
|
unit |
Optional[Unit]
|
property unit, see Unit in pint for more information. |
None
|
expr |
Optional[str]
|
property is computed as an expression of other attributes. |
None
|
dynamic |
bool
|
attributes values are recomputed each time the data is requested. expr must be defined if property is dynamic. |
False
|
read_only |
bool
|
attribute data is protected. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Attributes:
Name | Type | Description |
---|---|---|
kind |
PropertyKind
|
property kind if defined, otherwise None. |
unit |
Unit
|
property unit if defined, otherwise None. |
kind: PropertyKind
property
writable
🍋
Return the kind associated to the property if any, None otherwise.
Returns:
Type | Description |
---|---|
PropertyKind
|
Property kind. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.kind
<PropertyKind.GEOMETRY: 'GEOMETRY'>
unit: Unit
property
writable
🍋
Return the unit associated to the property if any, None otherwise.
Returns:
Type | Description |
---|---|
Unit
|
Pint Unit. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
prop_x = point_cloud.property("X")
prop_x.unit
<Unit('meter')>
ObjectRegion
🍋
Bases: ObjectAttribute
Region attribute class. See ObjectAttribute for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db |
ObjectDB
|
reference ObjectDB to get data from. |
required |
name |
str
|
region name. |
required |
condition |
Optional[str]
|
region is computed as a condition of other attributes. |
None
|
dynamic |
bool
|
attributes values are recomputed each time the data is requested. expr must be defined if property is dynamic. |
False
|
read_only |
bool
|
attribute data is protected. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
|