Point Cloud🍋
PointCloud
🍋
Bases: GeoRefObject
Object representing an arbitrary 3D cloud of points defined by its X, Y, Z geometry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
object name. |
required |
xyz
|
Optional[Data]
|
geometry data, respectively X, Y and Z. |
None
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
builtins: List[str]
property
🍋
Return the built-in object property names, defaults to X, Y, Z.
Returns:
Type | Description |
---|---|
List[str]
|
Built-in property names. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.builtins
['X', 'Y', 'Z']
default_support: AttributeSupportType
property
🍋
Return the default support type use for setting/getting attributes in the database.
Returns:
Type | Description |
---|---|
AttributeSupportType
|
The default support type. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.default_support
<AttributeSupportType.NODE: 'NODE'>
name: str
property
writable
🍋
Return the object name.
Returns:
Type | Description |
---|---|
str
|
Object name. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.name
'MyPointCloud'
aggregate(properties=None, agg_methods=[AggregationMethod.SUM, AggregationMethod.MIN, AggregationMethod.MAX, AggregationMethod.MEAN])
🍋
Return the object data grouped by location (X, Y).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[List[str]]
|
list of properties name to transfer to the GIS Object. Setting to None or empty list will select all existing properties. |
None
|
agg_methods
|
List[Union[AggregationMethod, Callable]]
|
aggregation data methods. See Pandas - Group By to find out supported methods. |
[SUM, MIN, MAX, MEAN]
|
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame of XY coordinates with aggregated data. |
Raises:
Type | Description |
---|---|
ValueError
|
|
AttributeError
|
One of the aggregation methods is not supported. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.aggregate(["Z"], ["max"])
X Y Z_max
0 0 1 2
1 3 4 5
2 6 7 8
3 9 10 11
4 12 13 14
5 15 16 17
6 18 19 20
7 21 22 23
8 24 25 26
9 27 28 29
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.aggregate()
X Y Z_sum Z_min Z_max Z_mean
0 0 1 2 2 2 2.0
1 3 4 5 5 5 5.0
2 6 7 8 8 8 8.0
3 9 10 11 11 11 11.0
4 12 13 14 14 14 14.0
5 15 16 17 17 17 17.0
6 18 19 20 20 20 20.0
7 21 22 23 23 23 23.0
8 24 25 26 26 26 26.0
9 27 28 29 29 29 29.0
bounds(region=None)
🍋
Return the object bounds, respectively separate minimum and maximum X, Y and Z.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
Optional[str]
|
name of the region or condition to optionally filter the data to be returned. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
XYZ bounding coordinates. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.bounds()
array([[ 0, 1, 2],
[27, 28, 29]])
centroid(region=None)
🍋
Return the object centroid, respectively separate mean X, Y and Z.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
Optional[str]
|
name of the region or condition to optionally filter the data to be returned. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
XYZ centroid coordinates. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.centroid()
array([13.5, 14.5, 15.5])
convert_to_gis_object(name, properties=None, agg_methods=[AggregationMethod.SUM, AggregationMethod.MIN, AggregationMethod.MAX, AggregationMethod.MEAN], region=None, region_agg=None)
🍋
Create a new GISObject from the GeoRefObject. The original GeoRefObject is not modified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the GISObject to create. |
required |
properties
|
Optional[List[str]]
|
list of properties name to transfer to the GIS Object. Setting to None or empty list will select all existing properties. |
None
|
agg_methods
|
List[Union[AggregationMethod, Callable]]
|
aggregation data methods. See Pandas - Group By to find out supported methods. |
[SUM, MIN, MAX, MEAN]
|
region
|
Optional[str]
|
Object region or condition to select data from. |
None
|
region_agg
|
Optional[RegionAggregationMethod]
|
Aggregation region method. |
None
|
Returns:
Type | Description |
---|---|
GISObject
|
GeoLime GISObject. |
Raises:
Type | Description |
---|---|
ValueError
|
'X' or 'Y' are part of the properties. |
AttributeError
|
One of the aggregation methods is not supported. |
coords(region=None)
🍋
Return the object coordinates, respectively X, Y, and Z as data arrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
Optional[str]
|
name of the region or condition to optionally filter the data to be returned. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
XYZ coordinates. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.coords()
array([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17],
[18, 19, 20],
[21, 22, 23],
[24, 25, 26],
[27, 28, 29]])
copy(name, attributes=None)
🍋
Copy the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the new object. |
required |
attributes
|
Optional[Union[List[str], str]]
|
list of attributes to copy. |
None
|
Returns:
Type | Description |
---|---|
GeoRefObject |
Raises:
Type | Description |
---|---|
ValueError
|
Given attributes (properties and regions) do not exist. |
data(names, region=None, support=None)
🍋
Return the attribute data corresponding to the given name(s) for the given support type and optionally in the given region. If no region is specified, it will return the whole data. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Union[List[str], str]
|
single or list of names to get data from. |
required |
region
|
str
|
name of the region or condition to optionally filter the data to be returned. |
None
|
support
|
AttributeSupportType
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
Underlying data array associated to the given attribute names. |
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region = xyz_sum < 10
obj.set_region("Lower10", xyz_region)
point_cloud.data("XYZ", "Lower10")
array([3])
delete_points(region)
🍋
Delete points in region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
str
|
Region or condition to select points. |
required |
describe(properties=None, **kwargs)
🍋
Generate descriptive statistics. For kwargs, see Pandas - Describe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[List[str]]
|
List of names to get data summary from. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.describe()
X Y Z
count 10.000000 10.000000 10.000000
mean 13.500000 14.500000 15.500000
std 9.082951 9.082951 9.082951
min 0.000000 1.000000 2.000000
25% 6.750000 7.750000 8.750000
50% 13.500000 14.500000 15.500000
75% 20.250000 21.250000 22.250000
max 27.000000 28.000000 29.000000
element_count(region=None)
🍋
Return the number of points in the cloud of points. Same as sample_count().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
Optional[str]
|
name of the region to optionally filter the data being counted. |
None
|
Returns:
Type | Description |
---|---|
int
|
Number of points. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.element_count()
10
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
xyz_region = xyz_sum < 10
point_cloud.set_region("REG", xyz_region)
point_cloud.element_count(region="REG")
1
generate_attribute_name(prefix='_', support=None)
🍋
Return a random unused name with the given prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
str
|
Prefix to start the attribute name with. |
'_'
|
support
|
Optional[AttributeSupportType]
|
Type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Returns:
Type | Description |
---|---|
str
|
The attribute name string. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.generate_attribute_name(prefix="new_prop")
'new_prop1b750b'
internals(support=None)
🍋
Return list of all existing internal properties for the specified support. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
support
|
Optional[AttributeSupportType]
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
Returns:
Type | Description |
---|---|
List
|
List containing all object internal property names. |
keep_only_points(region)
🍋
Keep points in region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
str
|
Region or condition to select points. |
required |
plot_2d(property, agg_method, region=None, region_agg=None, interactive_map=False, interactive_max_sample=5000, **kwargs)
🍋
Display the data on a regular plot or an interactive map.
Note
- 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 |
---|---|---|---|
property
|
str
|
object attribute to aggregate and display. |
required |
agg_method
|
AggregationMethod
|
aggregation data method. See Pandas - Group By to find out supported methods. |
required |
region
|
Optional[str]
|
Object region or condition to select data from. |
None
|
region_agg
|
Optional[RegionAggregationMethod]
|
Aggregation region method. |
None
|
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 along 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. |
properties(support=None)
🍋
Return list of all existing properties for the specified support. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
support
|
AttributeSupportType
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
List containing all object property names. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
point_cloud.properties()
['X', 'Y', 'Z', 'XYZ']
property(name, support=None, return_none=False)
🍋
Return the object property for the given name for the given support type. The support databased are disjoints, so it is possible to have properties carried by the nodes but not by the elements and vice-versa. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name to get property from. |
required |
support
|
AttributeSupportType
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
return_none
|
bool
|
if True, returns None instead of raising an error. |
False
|
Returns:
Type | Description |
---|---|
ObjectProperty
|
Object property associated to the given name. |
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
point_cloud.property("XYZ")
ObjectProperty
└─data()
└─dynamic ⇨ False
└─expr ⇨ None
└─kind ⇨ None
└─name ⇨ XYZ
└─read_only ⇨ False
└─unit ⇨ None
read_file(filepath, attributes=None)
classmethod
🍋
Read the object from its folder path. If it does not end with .geo
,
the suffix will automatically be appended. See global read_file()
provided for convenience.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the object folder path. |
required |
attributes
|
Optional[List[str]]
|
list of attributes to read from the object. |
None
|
Returns:
Type | Description |
---|---|
Union[GeoRefObject, GISObject]
|
The newly created object read from the file. |
Raise
ValueError: - if the path is invalid. - if the format version is not found in the manifest. - if the object type in the manifest does not match this object reader. - if there is any data file read error.
read_manifest(filepath)
staticmethod
🍋
Read the manifest first from the given object folder path (ending with .geo
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the object folder path. |
required |
Raise
ValueError: Path is invalid.
Returns:
Type | Description |
---|---|
The contents of the manifest file as JSON dictionary. |
refresh_attributes(names, support=None)
🍋
Recompute the given attribute(s) for the given support type. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Union[List[str], str]
|
list of names or single name of the attribute(s) to refresh. |
required |
support
|
AttributeSupportType
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Support type is not valid. |
region(name, support=None, return_none=False)
🍋
Return the object region for the given name for the given support type. The support databased are disjoints, so it is possible to have regions carried by the nodes but not by the elements and vice-versa. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name to get region from. |
required |
support
|
AttributeSupportType
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
return_none
|
bool
|
if True, returns None instead of raising an error. |
False
|
Returns:
Type | Description |
---|---|
ObjectRegion
|
Object region associated to the given name. |
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region = xyz_sum < 10
point_cloud.set_region("Lower10", xyz_region)
point_cloud.region("Lower10")
ObjectRegion
└─data()
└─dynamic ⇨ False
└─expr ⇨ None
└─name ⇨ Lower10
└─read_only ⇨ False
region_mask(region, support=None)
🍋
Get the boolean mask corresponding to the given region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
str
|
region or condition to filter data. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region = xyz_sum < 10
point_cloud.set_region("Lower10", xyz_region)
point_cloud.region_mask("Lower10")
array([ True, False, False, False, False, False, False, False, False, False])
regions(support=None)
🍋
Return a list of regions for a given GeoRefObject.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
support
|
Optional[AttributeSupportType]
|
support on which the regions are defined. Default value is None. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
List containing all user region names. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region = xyz_sum < 10
point_cloud.set_region("Lower10", xyz_region)
point_cloud.regions()
['Lower10']
remove_attribute(name, support=None)
🍋
Remove the object attribute (property or region) associated to the given name. Use a list of attribute names to remove all of them at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Union[str, List[str]]
|
name of the attribute to remove or a list of names of the attribute(s) to remove. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Support type is not valid. |
ValueError
|
Property is built-in or internal or doesn't exist. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region_inf10 = xyz_sum < 10
point_cloud.set_region("Lower10", xyz_region_inf10)
xyz_region_sup10 = xyz_sum > 10
point_cloud.set_region("Upper10", xyz_region_sup10)
# Remove only one attribute
point_cloud.remove_attribute("Lower10")
# Or remove multiple attributes
point_cloud.remove_attribute(["Lower10", "Upper10"])
True
remove_property(name, support=None)
🍋
Remove the object property associated to the given name. Use a list of property names to remove all of them at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Union[str, List[str]]
|
name of the property or a list of names of propertie(s) to remove. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Support type is not valid. |
ValueError
|
|
ValueError
|
Property is built-in or internal. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_sum_off1 = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ_off1", xyz_sum_off1)
# Remove only one property
point_cloud.remove_property("XYZ")
# Or remove multiple properties
point_cloud.remove_attribute(["XYZ", "XYZ_off1"])
True
remove_region(name, support=None)
🍋
Remove the object region associated to the given name. Use a list of region names to remove all of them at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Union[str, List[str]]
|
name of the region or a list of names of region(s) to remove. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
ValueError
|
Support type is not valid. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum)
xyz_region_inf10 = xyz_sum < 10
point_cloud.set_region("Lower10", xyz_region_inf10)
xyz_region_sup10 = xyz_sum > 10
point_cloud.set_region("Upper10", xyz_region_sup10)
# Remove only one region
point_cloud.remove_attribute("Lower10")
# Or remove multiple regions
point_cloud.remove_attribute(["Lower10", "Upper10"])
True
rename_attribute(names, support=None)
🍋
Rename the object attribute (property or region).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Dict[str, str]
|
a dictionary where each item is a pair of current name and new name. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
KeyError
|
Any of the current names is not found in the database. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
pc = geo.PointCloud("test", xyz)
data = np.arange(0., 10., 1.)
pc.set_property("PROP_1", data)
pc.set_property_expr("PROP_2", "PROP_1 + 1.")
pc.set_property_expr("PROP_3", "PROP_1 + 10.")
pc.rename_property({"PROP_1": "PROP_1_renamed"})
pc.rename_property({"PROP_2": "PROP_2_renamed", "PROP_3": "PROP_3_renamed"})
rename_property(names, support=None)
🍋
Rename the object property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Dict[str, str]
|
a dictionary where each item is a pair of current name and new name. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
KeyError
|
Any of the current names is not found in the database. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
pc = geo.PointCloud("test", xyz)
data = np.arange(0., 10., 1.)
pc.set_property("PROP_1", data)
pc.set_property_expr("PROP_2", "PROP_1 + 1.")
pc.set_property_expr("PROP_3", "PROP_1 + 10.")
pc.rename_property(names={"PROP_1": "PROP_1_renamed})
pc.rename_property(names={"PROP_2": "PROP_2_renamed", "PROP_3": "PROP_3_renamed"})
rename_region(names, support=None)
🍋
Rename the object region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Dict[str, str]
|
a dictionary where each item is a pair of current name and new name. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
KeyError
|
Any of the current names is not found in the database. |
!! example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
pc = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
pc.set_property("XYZ", xyz_sum)
xyz_region = xyz_sum < 2
pc.set_region("Lower2", xyz_region)
xyz_region = xyz_sum > 3
pc.set_region("Upper3", xyz_region)
xyz_region = xyz_sum < 10
pc.set_region("Lower10", xyz_region)
pc.rename_region(names={"Lower2": "Lower2_renamed"})
pc.rename_region(names={"Upper3": "Upper3_renamed", "Lower10": "Lower10_renamed"})
sample_count(region=None)
🍋
Return the number of points in the cloud of points. Same as element_count().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region
|
Optional[str]
|
name of the region to optionally filter the data being counted. |
None
|
Returns:
Type | Description |
---|---|
int
|
Number of points. |
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.sample_count()
10
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
xyz_region = xyz_sum < 10
point_cloud.set_region("REG", xyz_region)
point_cloud.sample_count(region="REG")
1
set_property(name, data, kind=None, unit=None, read_only=False, support=None)
🍋
Add or update the property corresponding to the given name(s) for the given support type. See also set_property_value() if you only need to update the data value of an existing property. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the property to create or update. |
required |
data
|
Data
|
property data array. |
required |
kind
|
PropertyKind
|
property kind, see PropertyKind for available kinds. |
None
|
unit
|
Unit
|
property unit, see Pint Unit for more information. |
None
|
read_only
|
bool
|
whether attribute data is protected. |
False
|
support
|
AttributeSupportType
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
from pint import Unit
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
# Setting a property using the method allowing to also define kind and units.
point_cloud.set_property("XYZ", xyz_sum, geo.PropertyKind.LENGTH, Unit("m"))
# Or using the shortcut method for simplicity. Note here, unit and kind
# are default to None.
point_cloud["XYZ"] = xyz_sum
# Setting the value to a string.
point_cloud.set_property("domain", "'hg'")
# or
point_cloud["domain"] = "'hg'"
set_property_expr(name, expr, dynamic=False, kind=None, unit=None, read_only=False, support=None, region=None, default=None)
🍋
Add or update the property corresponding to the given name(s) and expression for the given support type. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
property name. |
required |
expr
|
Union[str, int, float]
|
expression use to compute the property values. Use backquotes when attribute names contains whitespace. |
required |
dynamic
|
bool
|
set to True to have property values recomputed each time the data is requested. |
False
|
kind
|
Optional[PropertyKind]
|
property kind, see PropertyKind for available kinds. |
None
|
unit
|
Optional[Unit]
|
property unit, see Pint Unit for more information. |
None
|
read_only
|
bool
|
set to True if attribute data is protected. |
False
|
support
|
Optional[AttributeSupportType]
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
region
|
Optional[str]
|
region or condition in which to set the property data. |
None
|
default
|
Optional[str]
|
default value used outside of the region. This must be used in combination with a region parameter. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
# Or using the shortcut method for simplicity. Note that unit and kind
# default to None.
point_cloud["XYZ"] = "X * Y * Z"
# Create a property with an expression defined for a specific region
# and a default value for the remaining data.
point_cloud.set_property(
name="PROP",
expr="X * Y * Z",
dynamic=False,
region="(Z >= 14) & (Z <= 17)",
default="Y"
)
# Setting the value to a string.
point_cloud.set_property_expr("domain", "'hg'")
# or
point_cloud["domain"] = "'hg'"
set_property_value(name, data, support=None, region=None)
🍋
Update the named property with the given data for the given support type. The property must already exist, otherwise use set_property(). If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the property to update. |
required |
data
|
Data
|
property data array. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the property (e.g. node = vertex, element = triangles). |
None
|
region
|
Optional[str]
|
region or condition in which to set the property data. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
from pint import Unit
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum, geo.PropertyKind.LENGTH, Unit("m"))
point_cloud.set_property_value("XYZ", 2 * point_cloud.data("XYZ"))
set_region(name, data, read_only=False, support=None)
🍋
Add or update the region data corresponding to the given name(s) for the given support type. See also set_region_values() if you only need to update the data value of an existing region. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the property to create or update. |
required |
data
|
Data
|
region data array. |
required |
read_only
|
bool
|
set to True if region data is protected. |
False
|
support
|
AttributeSupportType
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
from pint import Unit
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_property("XYZ", xyz_sum, geo.PropertyKind.LENGTH, Unit("m"))
xyz_region = xyz_sum < 10
point_cloud.set_region('RegionTest', xyz_region)
set_region_condition(name, condition, dynamic=False, read_only=False, support=None, region=None)
🍋
Add or update the region data corresponding to the given name(s) and condition for the given support type. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
region name. |
required |
condition
|
str
|
condition use to compute the region values. Use backquotes when attribute names contains whitespace. |
required |
dynamic
|
bool
|
set to True to have region values recomputed each time the data is requested. |
False
|
read_only
|
bool
|
set to True if region data is protected. |
False
|
support
|
Optional[AttributeSupportType]
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
region
|
Optional[str]
|
region or condition in which to set the region data. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
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_region_condition('RegionTest', 'X + Y + Z < 10', False)
set_region_value(name, data, support=None, region=None)
🍋
Update the named region with the given data for the given support type. The region must already exist, otherwise use set_region(). If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the region to update. |
required |
data
|
Data
|
region data array. |
required |
support
|
Optional[AttributeSupportType]
|
type supporting the region (e.g. node = vertex, element = triangles). |
None
|
region
|
Optional[str]
|
region or condition in which to set the property data. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
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_region_condition('RegionTest', 'X + Y + Z < 10', False)
xyz_sum = np.sum(xyz, axis=1)
point_cloud.set_region_value('RegionTest', xyz_sum < 23)
to_csv(filename, names=None, region=None, skip_nan=False, sort_by=None, sort_ascending=True, mapping=None, support=None, **kwargs)
🍋
Export the given attribute(s) to a CSV-file. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
path to export the file to. |
required |
names
|
Union[List[str], str]
|
list of names or single name of the attribute(s) to export. If not specified, all attributes are exported. |
None
|
region
|
str
|
region name or condition to filter data to export. |
None
|
skip_nan
|
bool
|
True will drop NaN values from the exported file. Otherwise, NaN values will
be exported as NumericalConstants.NDV (-99999). To overwrite the NaN values,
use |
False
|
sort_by
|
Union[str, List[str]]
|
sort the data by the given attributes. |
None
|
sort_ascending
|
Union[bool, List[bool]]
|
sorting order when |
True
|
mapping
|
Dict
|
rename given columns in the exported CSV. |
None
|
support
|
AttributeSupportType
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
**kwargs
|
extra arguments to pass along to Pandas - To CSV. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
|
to_dataframe(names=None, region=None, support=None)
🍋
Export the given attribute(s) to a Pandas DataFrame. If no support is specified, the default database will be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
Union[List[str], str]
|
list of names or single name of the attribute(s) to export. If not specified, all attributes are exported. |
None
|
region
|
str
|
region name or condition to filter data to export. |
None
|
support
|
AttributeSupportType
|
type supporting the attributes (e.g. node = vertex, element = triangles). |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
|
to_file(filepath, attributes=None, version=None)
🍋
Write the object to the given folder path. If it does not end with .geo
,
the suffix will automatically be appended.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the object folder path. |
required |
attributes
|
Optional[List[str]]
|
list of attributes to write to the object. |
None
|
version
|
Optional[str]
|
specific version format to use. Use None will default to the latest available version. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
There is any data file write error. |
to_pyvista(properties=None, region=None)
🍋
Export GeoRefObject and selected properties to Pyvista PointSet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[Union[str, List[str]]]
|
Property or list of properties to export to Pyvista. |
None
|
region
|
Optional[str]
|
Object region or condition to select data from. |
None
|
Returns:
Type | Description |
---|---|
PointSet
|
PointSet object. |
transform(properties=None, agg_methods=None)
🍋
Return the object data grouped by location (X, Y).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[List[str]]
|
list of properties name to transfer to the GIS Object. Setting to None or empty list will select all existing properties. |
None
|
agg_methods
|
Optional[Union[AggregationMethod, Callable]]
|
aggregation data methods. See Pandas - Group By to find out supported methods. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame of XY coordinates with aggregated data. |
Raises:
Type | Description |
---|---|
ValueError
|
|
Example
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.aggregate(["Z"], ["max"])
X Y Z_max
0 0 1 2
1 3 4 5
2 6 7 8
3 9 10 11
4 12 13 14
5 15 16 17
6 18 19 20
7 21 22 23
8 24 25 26
9 27 28 29
import geolime as geo
import numpy as np
xyz = np.arange(30).reshape(10, 3)
point_cloud = geo.PointCloud("MyPointCloud", xyz)
point_cloud.aggregate()
X Y Z_sum Z_min Z_max Z_mean
0 0 1 2 2 2 2.0
1 3 4 5 5 5 5.0
2 6 7 8 8 8 8.0
3 9 10 11 11 11 11.0
4 12 13 14 14 14 14.0
5 15 16 17 17 17 17.0
6 18 19 20 20 20 20.0
7 21 22 23 23 23 23.0
8 24 25 26 26 26 26.0
9 27 28 29 29 29 29.0
translate_by(coord, expr, region=None)
🍋
Shift the given existing X, Y or Z coordinate by the given expression or value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coord
|
Union[Attribute, Coord]
|
coordinate property. |
required |
expr
|
str
|
expression use to compute the property values. Use backquotes when attribute names contains whitespace. |
required |
region
|
Optional[str]
|
region or condition in which to set the property data. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Coord doesn't exist. |
user_properties(support=None)
🍋
Return a list of properties for a given GeoRefObject including all the objects properties excluding built-in ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
support
|
Optional[AttributeSupportType]
|
support on which the properties are defined. Default value is None. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
List containing all user property names. |