Io
This module provides functions for reading and writing vector data (points, lines, polygons) using GeoPandas.
load_vector(path, engine='pyogrio', **kwargs)
Loads a vector dataset from the specified file path into a Vector object. Args: path (Union[str, Path]): The absolute or relative system path resolving to the vector file. engine (str): The GeoPandas engine to use for reading the file. Defaults to "pyogrio". **kwargs (Any): Additional keyword arguments to pass to the GeoPandas read_file function.
Returns:
| Name | Type | Description |
|---|---|---|
Vector |
Vector
|
A Vector object encapsulating the loaded GeoDataFrame. |
Source code in src/phytospatial/vector/io.py
resolve_vector(func)
A polymorphic decorator that intelligently resolves vector inputs into instantiated Vector objects.
This function analyzes the target method's signature, evaluating type annotations and parameter nomenclature. If a parameter expects a Vector but receives a string or Path, it intercepts the execution to perform disk I/O, seamlessly injecting the loaded Vector object before runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
The target function or class method expecting a Vector input. |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
Callable[..., Any]: The wrapped function executing with fully resolved Vector dependencies. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a resolved target parameter receives an argument that is neither a valid system path nor an instantiated Vector object. |
Source code in src/phytospatial/vector/io.py
save_vector(vector, path, driver=None, engine='pyogrio', **kwargs)
Saves a Vector object to the specified file path in a geospatial format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Vector
|
The Vector object to save. |
required |
path
|
Union[str, Path]
|
The absolute or relative system path where the vector file will be saved. |
required |
driver
|
str
|
The OGR driver to use for writing the file. Defaults to None. |
None
|
engine
|
str
|
The GeoPandas engine to use for writing the file. Defaults to "pyogrio". |
'pyogrio'
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the GeoPandas to_file function. |
{}
|