poly_mask
- poly_mask(data, lats, lons, missing=False)
New in Metview version 5.16.0.
If
data
is aFieldset
for 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). Ifdata
is aGeopoints
a 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
True
it 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()
.