# Difference between Crosses & Intersects - Shapely (Python)

I have two questions :

I have some lines (eg: road network). I want to find coordinates of each junction.

1. Should i use crosses or intersects function from python's Shapely module? They are giving different counts.

2. Moreover these functions return boolean value. How to get the junction coordinates ?

``````with open('./lines.geojson') as f:

line = []

for feature in lines['features']:
line.append(feature['geometry']['coordinates'])

count = 0
for i in range(len(line)-1):
j =i+1
while (j < len(line)):
l1 = LineString(line[i])
l2 = LineString(line[j])
if l1.crosses(l2)== True :
count =count+1
j = j+1
``````

1. From Shapely's doc:

`intersects()` is equivalent to the OR-ing of `contains()`, `crosses()`, `equals()`, `touches()`, and `within()`.

So there might be some cases where two lines intersect eachother without crossing, in particular when one line contains another or when two lines are equals.

More specifically:

`crosses()` returns `True` [...] if the dimension of the intersection is less than the dimension of the one or the other.

So if two lines overlap, they won't be considered as "crossing".

1. `intersection()` will return a geometric object.
• Thanks! just wanted to add that coordinates of the junction points can be extract using object.coords .
– Jio
Feb 28, 2016 at 10:33