cartagen.dilate_line

Contents

cartagen.dilate_line#

dilate_line(line, offset, cap_style='round', quad_segs=8)#

Dilate a line on both sides.

This algorithm proposed by Mustière [1] dilates a line on both sides by a given distance in meters. It is the basis of many mountain roads generalisation algorithm.

Parameters:
  • line (LineString) – The line to offset.

  • offset (float) – The length of the offset to apply in meters.

  • cap_style (str, optional) – The type of caps at the start and end of the provided line. Possible values are ‘round’ or ‘flat’.

  • quad_segs (int, optional) – The number of point allowed per circle quadrant when interpolating points using round method.

Returns:

left, right (tuple of list of LineString) – A tuple of two list of LineString, the left and the right side of the dilation.

See also

offset_line

This function preserves the relationship between the provided list of points and the result.

circle_interpolation

The function used to interpolate point along the quadrant of a circle.

Warning

This is basically a buffering algorithm rebuild from scratch. It is much slower than the buffer() algorithm proposed by shapely, so you better use this one. It exists only to be used alongside offset_line() to keep the relationship between the vertexes of the original line and the vertexes of the dilated one.

Notes

This algorithm returns dilation as lists of LineString. It often is composed of only one line but sometimes, it can creates multiple lines when the dilation creates holes.

References

Examples

>>> line = LineString([(1, 1), (2, 3), (5, 2)])
>>> dilate_line(line, 1.0)
([<LINESTRING (0.553 0.106, 0.715 0.042, 0.886 0.007, 1.06 0.002, 1.232 0.027,...>], [<LINESTRING (0.553 0.106, 0.404 0.197, 0.274 0.312, 0.165 0.449, 0.082 0.602...>])

(Source code)

../_images/dilate_line.png