mnns.line_functions
¶
Functions for random lines.
Functions:
| Name | Description |
|---|---|
add_points_to_line |
Given a list of points and a line, add the projected points to the line. |
create_line |
Generate random lines with random orientations with midpoints ranging from |
find_intersects |
Given a list of LineStrings, finds all the lines that intersect and where. |
find_line_intersects |
Given a list of LineStrings, find all the lines that intersect |
add_points_to_line
¶
add_points_to_line(
line: LineString,
points: list[Point],
return_ordering=False,
)
Given a list of points and a line, add the projected points to the line.
See general form at: https://stackoverflow.com/questions/34754777/shapely-split-linestrings-at-intersections-with-other-linestrings
Source code in mnns/line_functions.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
create_line
¶
create_line(
length: float = 1,
xmin: float = 0,
xmax: float = 1,
ymin: float = 0,
ymax: float = 1,
rng: Generator | None = None,
angle_dist: str = "uniform",
angle_kwargs: dict | None = None,
) -> LineString
Generate random lines with random orientations with midpoints ranging from
area from xmin to xmax and from ymin to ymax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Length of line |
1
|
xmin
|
float
|
Minimum x coordinate midpoint. |
0
|
xmax
|
float
|
Minimum x coordinate midpoint. |
1
|
ymin
|
float
|
Minimum y coordinate midpoint. |
0
|
ymax
|
float
|
Minimum y coordinate midpoint. |
1
|
rng
|
Generator
|
Generator object usually created from |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
LineString
|
LineString of the generated line. |
Source code in mnns/line_functions.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
find_intersects
¶
find_intersects(
lines: list,
) -> dict[tuple[int, int], Point]
Given a list of LineStrings, finds all the lines that intersect and where.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list of LineStrings
|
List of the LineStrings to find the intersections of. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
dict
|
Dictionary where the key is a tuple of the pair of intersecting lines and the value is the intersection locations. |
Source code in mnns/line_functions.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
find_line_intersects
¶
find_line_intersects(
ind: int, lines: list[LineString]
) -> dict[tuple[int, int], Point]
Given a list of LineStrings, find all the lines that intersect
with a specified line in the list given by the index ind.
Source code in mnns/line_functions.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |