Mar-26-2020, 12:33 AM
I'm trying to convert a Point from a Shapely Linestring.intersection() into (x, y) coordinates that I can use.
Why does this work:
Yet this doesn't?
Why does this work:
from shapely.geometry import LineString line1 = LineString([(1,0), (1,1)]) line2 = LineString([(0,1), (1,1)]) coords = [] coords.append(line2.intersection(line1).x) coords.append(line2.intersection(line1).y) print(coords)output:
[1.0, 1.0]
Yet this doesn't?
line1 = LineString([(1,790), (790,790)]) line2 = LineString([(self.player.rect.center), (self.station.rect.center)]) coords = [] coords.append(line2.intersection(line1).x) coords.append(line2.intersection(line1).y) print(coords)In the latter I get
Error: File "C:\Users\owner\Desktop\Python3\python 3.8\Projects\Last_man\main.py", line 1159, in draw
coords.append(line2.intersection(line1).x)
AttributeError: 'LineString' object has no attribute 'x'
I did try splitting the rect.centers into separate numbers, but that didn't help.