windkit.io.wasp.format_map#

windkit.io.wasp.format_map(points, header, elev=None, z0_left=None, z0_right=None, coord_decimals=1)[source]#

Format vector map data as .map file content.

Parameters:
  • points (sequence of array_like, shape (n_pts, 2)) – Coordinates of each line.

  • header (dict) – Must hold "description", the file’s first line, which carries the map’s CRS. May hold "fixed_points", "z_scale" and "z_offset", which default to the identity transform. Every other key is ignored, including the "epsg" that read_map() returns: the CRS is written only as part of "description", so changing "epsg" alone changes nothing.

  • elev (array_like, shape (n_lines,), optional) – Elevation of each line, nan where the line has none. Defaults to all nan.

  • z0_left (array_like, shape (n_lines,), optional) – Roughness lengths either side of each line, nan where the line has none. Defaults to all nan. A line must have both or neither.

  • z0_right (array_like, shape (n_lines,), optional) – Roughness lengths either side of each line, nan where the line has none. Defaults to all nan. A line must have both or neither.

  • coord_decimals (int, optional) – Decimal places written for each coordinate. Defaults to 1, which is what the WAsP GUI writes for a map in metres. This module cannot see the CRS, so a caller writing a geographic map must raise this itself: one decimal of a degree is roughly 11 km.

Returns:

The .map file content, with \n line endings.

Return type:

str

Raises:

ValueError – If header has no description, or an empty one, or one holding a line break; if header["fixed_points"] is not of shape (2, 4); if an attribute array’s length does not match points; if a line has only one of z0_left and z0_right; or if a member of points is not of shape (n_pts, 2).

See also

write_map

Write the same content to a file, without building the string.

_format_header

Build the "description" that header needs.