I have this graph, which contains a lot of lines defined by 2 points. Now I would like to generate a heatmap. The result should be something similar to http://docs.ggplot2.org/current/geom_raster.html, except the heat of each cell is defined as how many lines intersect it. The result should be a numpy array for PIL.
I considered two things so far, one would be to iterate over all lines and grids and calculate the distance from the two with this and if the distance is smaller than between two cells, it's in there. This is possible because in the actual data, the lines have a certain minimum length.
Another possibility to intersect each line with each grid cell and check if it's in there. But that sounds expensive, but more accurate. Along the lines that you check each horizontal/vertical line for intersection and check in which cell it is.
Data sample. It's an Array[Array[Int, Int]]
. Every pair of sub-arrays designates a line.