easy_vic_build.tools.dpc_func.basin_grid_class
Data structures and helpers for basin and grid GeoDataFrames.
This module defines lightweight geopandas.GeoDataFrame subclasses used by
the data-processing workflow:
Basinsfor basin polygons,Gridsfor grid polygons and center points,Grids_for_shpfor programmatically building grid layers from boundaries.
Functions
|
Create center and edge boundary polygons for a grid dataset. |
Classes
|
Basin polygon container. |
|
Grid polygon and point container. |
|
Grid container that can be initialized directly from grid-generation rules. |
- class easy_vic_build.tools.dpc_func.basin_grid_class.Basins(*args: Any, **kwargs: Any)[source]
Bases:
GeoDataFrameBasin polygon container.
This class inherits from
geopandas.GeoDataFrameand keeps type propagation behavior for operations that return new frames.- classmethod from_shapefile(shapefile_path, **kwargs)[source]
Build a
Basinsobject from a shapefile path.- Parameters:
shapefile_path (str or path-like) – Path to a vector file readable by
geopandas.read_file().**kwargs (dict) – Additional keyword arguments forwarded to
Basins(...).
- Returns:
Basin GeoDataFrame instance.
- Return type:
- __init__(*args: Any, **kwargs: Any) None
- class easy_vic_build.tools.dpc_func.basin_grid_class.Grids(*args: Any, **kwargs: Any)[source]
Bases:
GeoDataFrameGrid polygon and point container.
This class inherits from
geopandas.GeoDataFrameand is used to store both cell polygons (geometry) and cell centers (point_geometry).- classmethod from_shapefile(shapefile_path, **kwargs)[source]
Build a
Gridsobject from a shapefile path.- Parameters:
shapefile_path (str or path-like) – Path to a vector file readable by
geopandas.read_file().**kwargs (dict) – Additional keyword arguments forwarded to
Grids(...).
- Returns:
Grid GeoDataFrame instance.
- Return type:
- createBoundaryShp()[source]
Create center and edge boundary polygons for the grid.
- Returns:
(boundary_point_center_shp, boundary_point_center_x_y, boundary_grids_edge_shp, boundary_grids_edge_x_y).- Return type:
tuple
- __init__(*args: Any, **kwargs: Any) None
- class easy_vic_build.tools.dpc_func.basin_grid_class.Grids_for_shp(*args: Any, **kwargs: Any)[source]
Bases:
GridsGrid container that can be initialized directly from grid-generation rules.
Initialize a grid GeoDataFrame.
- Parameters:
data (object, optional) – Existing tabular/spatial data accepted by GeoDataFrame.
*args (tuple) – Positional arguments forwarded to
GeoDataFrame.geometry (str or array-like, optional) – Geometry column specification when
datais provided.crs (str or CRS, optional) – Coordinate reference system. Defaults to
"EPSG:4326"whencreate_grid_kwargsis used.create_grid_kwargs (dict, optional) – Arguments passed to
create_grid_shp(). When provided, generated grids are used as initialization data.**kwargs (dict) – Additional keyword arguments forwarded to
GeoDataFrame.
- __init__(data=None, *args, geometry=None, crs=None, create_grid_kwargs=None, **kwargs)[source]
Initialize a grid GeoDataFrame.
- Parameters:
data (object, optional) – Existing tabular/spatial data accepted by GeoDataFrame.
*args (tuple) – Positional arguments forwarded to
GeoDataFrame.geometry (str or array-like, optional) – Geometry column specification when
datais provided.crs (str or CRS, optional) – Coordinate reference system. Defaults to
"EPSG:4326"whencreate_grid_kwargsis used.create_grid_kwargs (dict, optional) – Arguments passed to
create_grid_shp(). When provided, generated grids are used as initialization data.**kwargs (dict) – Additional keyword arguments forwarded to
GeoDataFrame.
- create_grid_shp(gshp=None, cen_lons=None, cen_lats=None, stand_lons=None, stand_lats=None, res=None, adjust_boundary=True, crs=None, expand_grids_num=0, boundary=None)[source]
Build a grid GeoDataFrame from a target geometry/boundary.
- Parameters:
gshp (geopandas.GeoDataFrame, optional) – Target geometry container. The first row geometry is used as the default boundary when
boundaryis not provided.cen_lons (array-like, optional) – Grid-center longitudes used for direct grid construction.
cen_lats (array-like, optional) – Grid-center latitudes used for direct grid construction.
stand_lons (array-like, optional) – Standard longitude coordinates used to clip/build grids by boundary.
stand_lats (array-like, optional) – Standard latitude coordinates used to clip/build grids by boundary.
res (float, optional) – Grid resolution. If
None, only one boundary grid cell is built.adjust_boundary (bool, optional) – Whether to align boundaries to resolution-compatible edges.
crs (str or CRS, optional) – Output coordinate reference system. Defaults to
"EPSG:4326".expand_grids_num (int, optional) – Number of grid cells to expand outward beyond boundary.
boundary (sequence of float, optional) – Explicit boundary as
[xmin, ymin, xmax, ymax].
- Returns:
Generated grid GeoDataFrame, or
NonewhengshpisNone.- Return type:
geopandas.GeoDataFrame or None
- createBoundaryShp()
Create center and edge boundary polygons for the grid.
- Returns:
(boundary_point_center_shp, boundary_point_center_x_y, boundary_grids_edge_shp, boundary_grids_edge_x_y).- Return type:
tuple
- classmethod from_shapefile(shapefile_path, **kwargs)
Build a
Gridsobject from a shapefile path.- Parameters:
shapefile_path (str or path-like) – Path to a vector file readable by
geopandas.read_file().**kwargs (dict) – Additional keyword arguments forwarded to
Grids(...).
- Returns:
Grid GeoDataFrame instance.
- Return type:
- easy_vic_build.tools.dpc_func.basin_grid_class.createBoundaryShp(grid_shp)[source]
Create center and edge boundary polygons for a grid dataset.
- Parameters:
grid_shp (GeoDataFrame) – Grid GeoDataFrame containing
geometryandpoint_geometry.- Returns:
(boundary_point_center_shp, boundary_point_center_x_y, boundary_grids_edge_shp, boundary_grids_edge_x_y).- Return type:
tuple