I have a list of tuples containing x,y coordinate pairs. I wish to transform the list to a matrix, with xy coordinates representing indices of the matrix using numpy and without using a loop.
For any xy coordinate present in the list, have a 1 in the corresponding index position, and a 0 for any value not present in the list.
Original List:
a = [(0,0),(0,2),(0,3),(0,4),
(1,1),(1,2),(1,4),(2,2),
(3,2),(3,4), (4,4)]
a
Desired Output: Array of dimensions (5,5)
[
[1, 1, 0, 1, 1],
[1, 0, 0, 0, 0],
[1, 1, 1, 1, 0],
[0, 1, 0, 0, 0],
[1, 0, 0, 0, 0]
]
Similar to python - numpy create 2D mask from list of indices + then draw from masked array - Stack Overflow but not using scipy.