Merge all connected lines from a source. The source may be a MultiLineString, a sequence of LineString objects, or a sequence of objects than can be adapted to LineStrings. Returns a LineString or MultiLineString when lines are not contiguous.
(self, lines, directed=False)
| 87 | return shapely.polygonize_full(obs) |
| 88 | |
| 89 | def linemerge(self, lines, directed=False): |
| 90 | """Merge all connected lines from a source. |
| 91 | |
| 92 | The source may be a MultiLineString, a sequence of LineString objects, |
| 93 | or a sequence of objects than can be adapted to LineStrings. Returns a |
| 94 | LineString or MultiLineString when lines are not contiguous. |
| 95 | """ |
| 96 | source = None |
| 97 | if getattr(lines, "geom_type", None) == "MultiLineString": |
| 98 | source = lines |
| 99 | elif hasattr(lines, "geoms"): |
| 100 | # other Multi geometries |
| 101 | source = MultiLineString([ls.coords for ls in lines.geoms]) |
| 102 | elif hasattr(lines, "__iter__"): |
| 103 | try: |
| 104 | source = MultiLineString([ls.coords for ls in lines]) |
| 105 | except AttributeError: |
| 106 | source = MultiLineString(lines) |
| 107 | if source is None: |
| 108 | raise ValueError(f"Cannot linemerge {lines}") |
| 109 | return shapely.line_merge(source, directed=directed) |
| 110 | |
| 111 | def unary_union(self, geoms): |
| 112 | """Return the union of a sequence of geometries. |
nothing calls this directly
no test coverage detected