Skip to content

Geopackages

Neptune-Meister edited this page Sep 19, 2024 · 2 revisions

Geopackages - .gpkg

Summary

Geopackages (extension .gpkg) are only used in the HYFeatures Network formalism, where they are imported by the routine read_geopg, which identifies and reads specific geospatial layers from a GeoPackage based on data assimilation parameters. The output consists of four key geospatial layers: flowpaths, lakes, network, and nexus.

Read available layers

First, all available layers in the GeoPackage are read in using fiona.listlayers. In geopackages, layers correspond to different geospatial data stored in the GeoPackage. Layers by predetermined names and patterns (e.g., flowpaths, lakes, network) are found using the (case-insensitive) helper function find_layer_name. The following patterns are identified in the geopackages:

  • 'flowpaths': r'flow[-_]?paths?|flow[-_]?lines?'
  • 'flowpath_attributes': r'flow[-_]?path[-_]?attributes?|flow[-_]?line[-_]?attributes?'
  • 'lakes': r'lakes?'
  • 'nexus': r'nexus?'
  • 'network': r'network'

Read selected layers

Based on the waterbody_parameters and compute_parameters, certain layers are conditionally included for reading. For example, flowpaths and flowpath attributes are always read, whereas lakes and nexus layers are only read if break_network_at_waterbodies is enabled. The layer network is included if data assimilation features like streamflow nudging are enabled, and nexus is also read if hybrid routing is activated.

The ultimately selected layers are read using geopandas.read_file(), the computation of which is parallelized (depending on the number of CPUs cpu_pool). Each layer is read by specifying its name in the layer parameter of geopandas.read_file(). After reading the data, the flowpaths and flowpath_attributes layers are merged based on a common column (renaming link to id if necessary). This merged dataframe represents the full dataset of river flow paths with their attributes.

Resulting layers

The function returns four dataframes corresponding to the specific layers read from the GeoPackage:

  • flowpaths: Contains merged data from flowpaths and flowpath attributes, representing river flow lines with their associated properties.
  • lakes: Contains lake geometries if they are included in the dataset.
  • network: Represents the full hydrologic network, potentially used for data assimilation.
  • nexus: Nodes in the network that connect different flow paths or waterbodies.
Clone this wiki locally