Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 1.35 KB

poly_mask.rst

File metadata and controls

26 lines (18 loc) · 1.35 KB

poly_mask

.. py:function:: poly_mask(data, lats, lons, missing=False)

   *New in Metview version 5.16.0*.

   If ``data`` is a :class:`Fieldset` for each field :func:`poly_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). If ``data`` is a :class:`Geopoints` a similar operation is performed for all the points in it.

   :param data: input data
   :type data: :class:`Fieldset` or :class:`Geopoints`
   :param lats: the latitude of the polygon points. Use a list of ndarrays to define multiple polygons.
   :type lats: ndarray or list of ndarrays
   :param lons: the longitude of the polygon points. Use a list of ndarrays to define multiple polygons.
   :type lons: ndarray or list of ndarrays
   :param missing: 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.
   :type missing: bool
   :rtype: :class:`Fieldset` or :class:`Geopoints`

   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 :func:`mask`, :func:`rmask`, :func:`bitmap` and :func:`nobitmap`.

.. mv-minigallery:: poly_mask