So I have a shapely
LineString
:
print np.round(shapely_intersecting_lines.coords).astype(np.int)
>>> array([[ 1520, -1140
Here's Bresenhams line algorithm as a generator. If you want a list just call list() on the output:
def line(x0, y0, x1, y1):
deltax = x1-x0
dxsign = int(abs(deltax)/deltax)
deltay = y1-y0
dysign = int(abs(deltay)/deltay)
deltaerr = abs(deltay/deltax)
error = 0
y = y0
for x in range(x0, x1, dxsign):
yield x, y
error = error + deltaerr
while error >= 0.5:
y += dysign
error -= 1
yield x1, y1