Geom
This module provides geometric operations and spatial analysis functions for vector data.
filter_vector(vector, condition, inplace=False)
Filters the geometries in the Vector based on a boolean condition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The input Vector object containing geometries to be filtered. |
required |
condition
|
Union[Series, Callable]
|
A boolean Series or a callable function that returns a boolean Series for filtering. |
required |
inplace
|
bool
|
If True, modifies the input Vector in place. If False, returns a new Vector with filtered geometries. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object with geometries filtered based on the condition. If inplace is True, returns the modified input Vector. |
Source code in src/phytospatial/vector/geom.py
force_Z(vector, dimensionality=2, inplace=False)
Alters the geometric dimensionality of the spatial data by either stripping or appending a Z-axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The input Vector object containing the geometries to transform. |
required |
dimensionality
|
int
|
The target number of spatial dimensions. Must be strictly 2 or 3. Defaults to 2. |
2
|
inplace
|
bool
|
If True, applies the dimensionality transformation directly to the underlying GeoDataFrame of the input Vector. If False, generates and returns a new Vector instance. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object ensuring all geometries conform to the requested dimensionality. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided dimensionality argument is not exactly 2 or 3. |
Source code in src/phytospatial/vector/geom.py
select_columns(vector, columns, inplace=False)
Selects a subset of columns from the Vector's GeoDataFrame, ensuring that the geometry column is retained.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The input Vector object containing the GeoDataFrame. |
required |
columns
|
list
|
A list of column names to select. |
required |
inplace
|
bool
|
If True, modifies the input Vector in place. If False, returns a new Vector with the selected columns. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object with the selected columns. If inplace is True, returns the modified input Vector. |
Source code in src/phytospatial/vector/geom.py
to_crs(vector, target_crs, inplace=False)
Reprojects the geometries in the Vector to a specified target Coordinate Reference System (CRS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The input Vector object containing geometries to be reprojected. |
required |
target_crs
|
Union[str, int, dict]
|
The target CRS to which the geometries will be reprojected. |
required |
inplace
|
bool
|
If True, modifies the input Vector in place. If False, returns a new Vector with reprojected geometries. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object with geometries reprojected to the target CRS. If inplace is True, returns the modified input Vector. |
Source code in src/phytospatial/vector/geom.py
validate(vector, fix_invalid=True, drop_invalid=True, inplace=False)
Validates the geometries in the Vector, optionally fixing or dropping invalid geometries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The input Vector object containing geometries to be validated. |
required |
fix_invalid
|
bool
|
If True, attempts to fix invalid geometries using a zero-width buffer. Defaults to True. |
True
|
drop_invalid
|
bool
|
If True, drops geometries that remain invalid after the fix attempt. Defaults to True. |
True
|
inplace
|
bool
|
If True, modifies the input Vector in place. If False, returns a new Vector with validated geometries. Defaults to False |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object with validated geometries. If inplace is True, returns the modified input Vector. |