pyorps.io
Input/output operations for geospatial data.
This module provides: 1. Base classes for working with vector and raster geospatial data 2. Dataset implementations for local and in-memory data sources 3. Web Feature Service (WFS) data loading capabilities 4. Factory functions to create appropriate dataset instances
- class pyorps.io.GeoDataset(file_source, crs=None)[source]
Bases:
ABC- data: GeoDataFrame | ndarray | None = None
- class pyorps.io.VectorDataset(file_source, crs=None, bbox=None, mask=None)[source]
Bases:
GeoDataset,ABC- Parameters:
- mask: Polygon | GeoDataFrame | tuple | None = (None,)
- class pyorps.io.RasterDataset(file_source, crs=None)[source]
Bases:
GeoDataset,ABC- transform: Affine
- class pyorps.io.InMemoryVectorDataset(file_source, crs=None, bbox=None, mask=None)[source]
Bases:
VectorDataset- Parameters:
- class pyorps.io.LocalVectorDataset(file_source, crs=None, bbox=None, mask=None)[source]
Bases:
InMemoryVectorDataset- Parameters:
- class pyorps.io.WFSVectorDataset(file_source, crs=None, bbox=None, mask=None)[source]
Bases:
LocalVectorDataset- Parameters:
- class pyorps.io.LocalRasterDataset(file_source, crs=None)[source]
Bases:
RasterDataset
- class pyorps.io.InMemoryRasterDataset(file_source, crs, transform)[source]
Bases:
RasterDataset
- pyorps.io.initialize_geo_dataset(file_source, crs=None, bbox=None, mask=None, transform=None)[source]
Factory function to create the appropriate GeoDataset instance based on the provided input.
- Parameters:
file_source (str | dict | GeoDataFrame | GeoSeries | ndarray) – Source data (file path, GeoDataFrame, URL dict, numpy array, etc.)
crs (str | None) – Coordinate reference system
bbox (Polygon | GeoDataFrame | GeoSeries | tuple[float, float, float, float] | None) – Bounding box for vector datasets
mask (Polygon | GeoDataFrame | tuple | None) – Mask for vector datasets
transform (Affine | None) – Affine transform for in-memory raster datasets
- Returns:
An appropriate GeoDataset subclass instance
- Return type:
Examples
# From local vector file vector_dataset = create_geo_dataset(“path/to/shapefile.shp”, crs=”EPSG:4326”)
# From GeoDataFrame vector_dataset = create_geo_dataset(gdf, bbox=(x1, y1, x2, y2))
# From WFS source wfs_dataset = create_geo_dataset({“url”: “https://example.com/wfs”,
“layer”: “layer1”})
# From local raster file raster_dataset = create_geo_dataset(“path/to/dem.tif”)
# From numpy array raster_dataset = create_geo_dataset(array_data, transform=transform,
crs=”EPSG:4326”)
- pyorps.io.load_from_wfs(url, layer, bbox=None, mask=None, filter_params=None, auto_match=True, max_workers=4)[source]
Load data from a Web Feature Service (WFS) using chunked loading.
- Parameters:
url (str) – The base URL of the WFS service
layer (str) – Name of the layer to retrieve
bbox (Polygon | GeoDataFrame | GeoSeries | tuple[float, float, float, float] | None) – Optional bounding box to limit the query extent (minx, miny, maxx, maxy)
mask (Polygon | GeoDataFrame | tuple | None) – Optional geometry mask to limit the query (Shapely Polygon, GeoDataFrame, or GeoSeries)
filter_params (dict | None) – Additional WFS parameters to filter results
auto_match (bool) – Whether to attempt finding similar layer names if exact match not found
max_workers (int) – Maximum number of parallel threads to use
- Returns:
Loaded GeoDataFrame or None if no data could be loaded
- Raises:
WFSLayerNotFoundError – If the layer cannot be found and auto_match is False
- Return type:
GeoDataFrame | None
- exception pyorps.io.WFSConnectionError[source]
Bases:
WFSErrorException raised for connection issues with WFS services.
- exception pyorps.io.WFSResponseParsingError[source]
Bases:
WFSErrorException raised when parsing WFS responses fails.
- exception pyorps.io.WFSLayerNotFoundError[source]
Bases:
WFSErrorException raised when a requested layer cannot be found.
Modules
PYORPS: An Open-Source Tool for Automated Power Line Routing |
|
PYORPS: An Open-Source Tool for Automated Power Line Routing |