wradlib.zonalstats.ZonalDataBase

class wradlib.zonalstats.ZonalDataBase(src, trg=None, buf=0.0, srs=None, **kwargs)

Base class for managing 2-dimensional zonal data.

For target polygons from either source points or source polygons. Provides the basic design for all other classes.

If no source points or polygons can be associated to a target polygon (e.g. no intersection), the created destination layer will be empty.

Data Model is built upon OGR Implementation of ESRI Shapefile

  • one src DataSource (named ‘src’) holding source polygons or points
  • one trg DataSource (named ‘trg’) holding target polygons
  • one dst DataSource (named ‘dst’) holding intersection polygons/points related to target polygons with attached index and weights fields

By using OGR there are no restrictions for the used source grids.

Warning

Writing shapefiles with the wrong locale settings can have impact on the type of the decimal. If problem arise use LC_NUMERIC=C in your environment.

Parameters:
  • src (sequence of source points (shape Nx2) or polygons (shape NxMx2) or) – ESRI Shapefile filename containing source points/polygons or DataSource object
  • trg (sequence of target polygons (shape Nx2, num vertices x 2) or) – ESRI Shapefile filename containing target polygons or DataSource object
Keyword Arguments:
 
  • buf (float) – (same unit as coordinates) Points/Polygons will be considered inside the target if they are contained in the buffer.
  • srs (object) – OGR.SpatialReference will be used for DataSource object. src and trg data have to be in the same srs-format

Examples

See ZonalData.

dump_vector(filename[, driver, remove]) Output source/target grid points/polygons to ESRI_Shapefile
get_isec(idx) Returns intersections
get_source_index(idx) Returns source indices referring to target polygon idx
load_vector(filename) Load source/target grid points/polygons into in-memory Shapefile
count_intersections Returns number of intersections
isecs Returns intersections
srs Returns SpatialReferenceSystem object