0

I get this error:

ValueError: No Shapely geometry can be created from null value

on some occassions where I am trying to find the common or shared paths between two linestrings. I am using the ops.shared_paths method.

Suppose I have the following linestrings with their geometries:

geom1 = LINESTRING (-79.38545 43.65393, -79.38578 43.65472, -79.38578 43.65472, -79.38596 43.65515, -79.38596 43.65515, -79.38601 43.65525, -79.38601 43.65525, -79.38551 43.65535, -79.38551 43.65535, -79.38417 43.65564, -79.38417 43.65564, -79.38283 43.65593, -79.38283 43.65593, -79.38163 43.65618, -79.38163 43.65618, -79.38105 43.65631, -79.38105 43.65631, -79.38056 43.65641, -79.38056 43.65641, -79.38024 43.65645, -79.38024 43.65645, -79.37979 43.65635, -79.37979 43.65635, -79.3803 43.65645, -79.3803 43.65645, -79.38073 43.65638)
geom2 = LINESTRING (-79.38621 43.65786, -79.38634 43.65812, -79.38634 43.65812, -79.38634 43.65812, -79.38634 43.65812, -79.38586 43.65705, -79.38586 43.65705, -79.38562 43.65648, -79.38562 43.65648, -79.3852 43.65542, -79.3852 43.65542, -79.38452 43.65557, -79.38452 43.65557, -79.38387 43.6557, -79.38387 43.6557, -79.38373 43.65573, -79.38373 43.65573, -79.38344 43.65502, -79.38344 43.65502, -79.38292 43.65372, -79.38292 43.65372, -79.38245 43.65251, -79.38245 43.65251, -79.38231 43.65215, -79.38231 43.65215, -79.38221 43.65205)

So when I try:

ops.shared_paths(geom1, geom2)

I get this weird output first:

4169999999997 43.655639999999998

And then the ValueError message.

It is expected that it outputs a GeometryCollection object consisting of a "forward" and a "backward" MultiLineStrings. In fact, visualizing these two linestrings, they have a shared path:

enter image description here

where the red linestring is geom1 and the blue linestring is geom2. I'm just not sure why I get the weird error and why it complains. There clearly is a shared path but it doesn't report it and just reports an error instead. For other pairs of linestrings, the behavior is quite unpredictable. Sometimes, it reports it correctly (whether there is a shared path or none). But there are times when it reports an error instead (regardless of whether there was a shared path or none).

M. Fire
  • 117
  • 2
  • 6

0 Answers0