pywasp.polygons_to_lines

pywasp.polygons_to_lines(gdf, lctable=None, map_type='roughness', return_lctable=False, external_roughness=None, check_errors=True, snap=True)[source]

Converts a geopandas.GeoDataFrame vectormap object to a xarray.DataArray rastermap object.

Warning

This function is experimental and its signature may change.

Parameters:
  • gdf (geopandas.GeoDataFrame) – Vectormap with only polygons and at minimum columns ‘z0’ or ‘id’ (only allowed when a landcover table lct is specified). Can also contain a column ‘d’ that specifies the displacement height and a column ‘desc’, which describes the landcover in the corresponding polygon.

  • lctable (LandCoverTable) – Landcover table specifying the landcover classes and their mappings to roughness and displacement height. Required for ‘landcover’ maps that only have an ‘id’ column. The default is None, which means that there is a ‘z0’ column in the dataframe that specifies the roughness length.

  • map_type ({"roughness","landcover"}) – Whether the output is a geopandas dataframe with roughness (z0) or id change lines, default “roughness”.

  • return_lctable (bool) – Whether to return the landcover table, default False

  • external_roughness (float, optional) – Default None, meaning that segments from polygons that border a unspecified area are removed. If a float is specified, the roughness of these unspecified areas are assigned this value.

  • check_errors (check for the following errors in the map) – 1) No polygons are allowed to overlap 2) If external_roughness is None: The exterior boundary (convex hull) given by the extent of the polygons must not contain holes. 3) If external_roughness is a float: Throw a warning if there is holes in the polygons you have specified.

  • snap (bool) – If True, insert extra vertices if a vertex is present in one polygon but not in the one that is touching it

Returns:

gdf (geopandas.GeoDataFrame) – Vectormap with LineString and columns <var>_left and <var>_right

Notes

if map_type=”landcover” and return_lctable is True also returns:

lct: wk.LandCoverTable

landcover table containing the mapping of columns id_left,id_right to roughness length z0, displacement height d and a description desc