poly_mask
- poly_mask(data, lats, lons, missing=False)
New in Metview version 5.16.0.
If
datais aFieldsetfor each fieldpoly_mask()creates a field containing 0 or 1 values according to whether a grid point is inside (1) or outside (0) the specified polygon(s). Ifdatais aGeopointsa similar operation is performed for all the points in it.- Parameters
lats (ndarray or list of ndarrays) – the latitude of the polygon points. Use a list of ndarrays to define multiple polygons.
lons (ndarray or list of ndarrays) – the longitude of the polygon points. Use a list of ndarrays to define multiple polygons.
missing (bool) – when it is
Trueit will change the behaviour so that points outside the polygon(s) will become missing values and point inside the polygon(s) retain their original value.
- Return type
The polygons are automatically closed if the first and last coordinates are not the same. If multiple polygons are specified the output mask is generated by forming their union.
Note
See also
mask(),rmask(),bitmap()andnobitmap().