opendrift.readers.reader_shape ============================== .. py:module:: opendrift.readers.reader_shape Attributes ---------- .. autoapisummary:: opendrift.readers.reader_shape.logger Classes ------- .. autoapisummary:: opendrift.readers.reader_shape.Reader Functions --------- .. autoapisummary:: opendrift.readers.reader_shape.unwrap Module Contents --------------- .. py:data:: logger .. py:class:: Reader(shapes, proj4_str='+proj=lonlat +ellps=WGS84', invert=False, land_buffer_distance=None) Bases: :py:obj:`opendrift.readers.basereader.BaseReader`, :py:obj:`opendrift.readers.basereader.ContinuousReader` The shape reader can be used to load generic shapes as the 'landmask' variable. Args: :param shapes: shapely geometries. :type shapes: iterable. :param proj4_str: Proj.4 string of shape file projection coordinates (default: '+proj=lonlat +ellps=WGS84'). :type proj4_str: string. Common constructor for all readers .. py:attribute:: name :value: 'shape' .. py:attribute:: variables :value: ['land_binary_mask'] .. py:attribute:: proj4 :value: None .. py:attribute:: crs :value: None .. py:attribute:: polys :value: None .. py:attribute:: land :value: None .. py:attribute:: always_valid :value: True .. py:method:: from_shpfiles(shpfiles, proj4_str='+proj=lonlat +ellps=WGS84', invert=False, land_buffer_distance=0) :staticmethod: Construct a shape-reader from shape-files (.shp) Args: :param shapes: shape-file or files (.shp) :type shapes: string or list of file names as strings. :param proj4_str: Proj.4 string of shape file projection coordinates (default: '+proj=lonlat +ellps=WGS84'). :type proj4_str: string. :type land_buffer_distance: float. Buffer distance around polygons .. py:attribute:: _land_kdtree :value: None .. py:attribute:: _land_kdtree_buffer_distance :value: None .. py:attribute:: invert :value: False .. py:attribute:: z :value: None .. py:method:: __on_land__(x, y) .. py:method:: get_variables(requestedVariables, time=None, x=None, y=None, z=None) Get binary mask of whether elements are on land or not. Args: x (deg[]): longitude (decimal degrees) y (deg[]): latitude (decimal degrees) ... x, y is given in reader local projection. Returns: Binary mask of point x, y on land. .. py:method:: get_nearest_outside(x, y, buffer_distance) Determine the nearest point outside the loaded polygons, including an additional buffer distance Args: x (deg[]): longitude (decimal degrees) or projected x coordinate y (deg[]): latitude (decimal degrees) or projected y coordinate buffer_distance: buffer zone around polygons ... x, y, buffer are given in reader local projection. Returns: lon, lat, and distance to nearest points .. py:function:: unwrap(geom) Unwrap a shapely geometry or a list thereof into boundary coordinates Returns: array of shape (2, N)