I am working with intersection of polygon and line segments (continued from a previous question).
When a Line intersects with a Polygon, the result is a LineString; When a LineRing intersects with a Line, the result is a MultiPoint.
While in most cases, the intersection is only in two points, the case I have encountered is multiple intersections (in figure).
The indicated yellow lines are the ones that intersect only at two points, and thus result in no errors. But when the program begins intersection of the LineString and LinearRing where there is multiple intersections, the following error shows up.
NotImplementedError: Multi-part geometries do not themselves provide the array interface
Would there be any way to work around this? I am not at liberty to share the code, but any specific, additional information can be provided.
To provide some additional context, I am appending each intersection resultant MultiPoint and MultiLineString to a 'list' of previous results, respectively. So while the previous results were only a pair of XY coordinates, multiple intersections give multiple results. The line of code that results in the error is when I try to convert the 'list' of LineString (intersection) results to a MultiLineString using MultiLineString()
For instance, multi_line
is the list of intersections resulting from line.intersection(polygon)
. This list needs to written to a MultiLineString for creating a new shapefile.
MultipleLine = MultiLineString(multi_line)