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:

  • Basins for basin polygons,

  • Grids for grid polygons and center points,

  • Grids_for_shp for programmatically building grid layers from boundaries.

Functions

createBoundaryShp(grid_shp)

Create center and edge boundary polygons for a grid dataset.

Classes

Basins(*args, **kwargs)

Basin polygon container.

Grids(*args, **kwargs)

Grid polygon and point container.

Grids_for_shp(*args, **kwargs)

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: GeoDataFrame

Basin polygon container.

This class inherits from geopandas.GeoDataFrame and keeps type propagation behavior for operations that return new frames.

classmethod from_shapefile(shapefile_path, **kwargs)[source]

Build a Basins object 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:

Basins

__init__(*args: Any, **kwargs: Any) None
class easy_vic_build.tools.dpc_func.basin_grid_class.Grids(*args: Any, **kwargs: Any)[source]

Bases: GeoDataFrame

Grid polygon and point container.

This class inherits from geopandas.GeoDataFrame and is used to store both cell polygons (geometry) and cell centers (point_geometry).

classmethod from_shapefile(shapefile_path, **kwargs)[source]

Build a Grids object 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:

Grids

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: Grids

Grid 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 data is provided.

  • crs (str or CRS, optional) – Coordinate reference system. Defaults to "EPSG:4326" when create_grid_kwargs is 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 data is provided.

  • crs (str or CRS, optional) – Coordinate reference system. Defaults to "EPSG:4326" when create_grid_kwargs is 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 boundary is 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 None when gshp is None.

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 Grids object 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:

Grids

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 geometry and point_geometry.

Returns:

(boundary_point_center_shp, boundary_point_center_x_y, boundary_grids_edge_shp, boundary_grids_edge_x_y).

Return type:

tuple