I am trying to create an image of a specific size of pixels and draw in it several trajectories that I have ordered in a dataframe by x and y coordinates. An example of how the dataframe looks with 2 trajectories would be like this:
In [60]: df
Out[60]:
TRACK_ID x y
1 16.130 8.993
1 15.817 8.699
1 16.076 8.712
1 16.176 8.191
1 16.486 8.106
2 16.308 8.500
2 16.270 8.441
2 16.042 8.474
2 15.966 8.487
2 15.882 8.431
2 15.869 8.419
Next, I use PIL to generate the image:
from PIL import Image
from PIL import ImageDraw
img = Image.new("RGB", (512,512), "black")
draw = ImageDraw.Draw(img)
coords = ['x','y']
dotSize = 2
for (x,y) in coords:
draw.line([x,y,x+dotSize-1,y+dotSize-1], fill="red")
img.show()
This works fine for points (x, y) but I must enter one by one, how can I do to enter my complete columns as independent paths? Is there a simpler way to pass my columns to a binary image? Thanks