add_line

Maps.add_line(xy, xy_crs=4326, connect='geod', n=None, del_s=None, mark_points=None, layer=None, **kwargs)

Draw a line by connecting a set of anchor-points.

The points can be connected with either “geodesic-lines”, “straight lines” or “projected straight lines with respect to a given crs” (see connect kwarg).

Parameters:
  • xy (list, set or numpy.ndarray) – The coordinates of the anchor-points that define the line. Expected shape: [(x0, y0), (x1, y1), …]

  • xy_crs (any, optional) – The crs of the anchor-point coordinates. (can be any crs definition supported by PyProj) The default is 4326 (e.g. lon/lat).

  • connect (str, optional) –

    The connection-method used to draw the segments between the anchor-points.

    • ”geod”: Connect the anchor-points with geodesic lines

    • ”straight”: Connect the anchor-points with straight lines

    • ”straight_crs”: Connect the anchor-points with straight lines in the xy_crs projection and reproject those lines to the plot-crs.

    The default is “geod”.

  • n (int, list or None optional) –

    The number of intermediate points to use for each line-segment.

    • If an integer is provided, each segment is equally divided into n parts.

    • If a list is provided, it is used to specify “n” for each line-segment individually.

      (NOTE: The number of segments is 1 less than the number of anchor-points!)

    If both n and del_s is None, n=100 is used by default!

    The default is None.

  • del_s (int, float or None, optional) –

    Only relevant if connect=”geod”!

    The target-distance in meters between the subdivisions of the line-segments.

    • If a number is provided, each segment is equally divided.

    • If a list is provided, it is used to specify “del_s” for each line-segment individually.

      (NOTE: The number of segments is 1 less than the number of anchor-points!)

    The default is None.

  • mark_points (str, dict or None, optional) –

    Set the marker-style for the anchor-points.

    • If a string is provided, it is identified as a matploltib “format-string”, e.g. “r.” for red dots, “gx” for green x markers etc.

    • if a dict is provided, it will be used to set the style of the markers e.g.: dict(marker=”o”, facecolor=”orange”, edgecolor=”g”)

    See https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.html for more details

    The default is “o”

  • layer (str, int or None) – The name of the layer at which the line should be drawn. If None, the layer associated with the used Maps-object (e.g. m.layer) is used. Use “all” to add the line to all layers! The default is None.

  • kwargs

    additional keyword-arguments passed to plt.plot(), e.g. “c” (or “color”), “lw” (or “linewidth”), “ls” (or “linestyle”), “markevery”, etc.

    See https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.plot.html for more details.

Returns:

  • out_d_int (list) – Only relevant for connect=”geod”! (An empty list is returned otherwise.) A list of the subdivision distances of the line-segments (in meters).

  • out_d_tot (list) – Only relevant for connect=”geod” (An empty list is returned otherwise.) A list of total distances of the line-segments (in meters).