windkit.io.wasp.write_map#
- windkit.io.wasp.write_map(filepath, points, header, elev=None, z0_left=None, z0_right=None, coord_decimals=1)[source]#
Write vector map data to a WAsP
.mapfile.The file is written with CRLF line endings, which the WAsP GUI requires. A line with both an elevation and a roughness change is written as a four-field combination line; one with neither is written with a bare point count.
read_map()reads back what this writes.The file is written as UTF-8, one of the encodings
read_map()sniffs for. The WAsP map editor reads the header in the Windows ANSI code page, so keep descriptions ASCII when the file is meant to be opened there.- Parameters:
filepath (str or Path) – Path to the output file.
points (sequence of array_like, shape (n_pts, 2)) – Coordinates of each line.
header (dict) – Must hold
"description". Seeformat_map().elev (array_like, shape (n_lines,), optional) – Elevation of each line, nan where the line has none.
z0_left (array_like, shape (n_lines,), optional) – Roughness lengths either side of each line, nan where the line has none.
z0_right (array_like, shape (n_lines,), optional) – Roughness lengths either side of each line, nan where the line has none.
coord_decimals (int, optional) – Decimal places written for each coordinate. Defaults to 1. See
format_map().
- 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).
Examples
Round-trip a
.map. The coordinates are written with one decimal, so passcoord_decimalstoo if the map is in degrees rather than metres.>>> data = read_map("in.map") >>> write_map("out.map", **data)