I've been given some data in a particularly (in my opinion) odd way, namely an array of points connected to each other via lines, whereby each line has for a lack of a better word, "attribute" assigned to it. Being a numerical value between {1,4}.
In poorly hacked up code, I've managed to simply draw the lines connecting the points in a plane for visualizations sake.
Each blue line represents a value between 1 and 4, and the black lines are a simple grid. For clarity. The grid goes from [0,9] in y and [0,8] in x at 0.5 steps.
Graphics[{{Blue, Line[pts]}, lho, lver}, Frame -> True,
PlotRange -> {{0, 8}, {0, 9}}]
I would like to build up an average of each 1x1 grid square of the values of each line inside said square. This way each square will become a single point value that I can now attribute to a {x,y,z} form with z being the average and x, y being coordinates in the grid.
For example, Square 1:1, starting at the bottom left has 8 lines within it, 4 of them having the value 2.45556, and the other 4 having the value 1.6690. Doing the math (4*2.45556+4*1.6690)/8 = 2.06228
Doing this for another square, such as 1:4 (starting from the left corner bottom corner again) would only see two lines two of which are shared from 1:1, so assuming those two lines both have the value 2.45556, it's average would be also 2.4556.
I can now have the points at {0.5 ,1.5 ,2.06228} and {3.5,1.5,2.45556} for further analysis. This particular example as a demonstration has 64 squares in total, however this will scale up to several hundred later.
First, is it possible to give a line a numerical value? If such a thing is possible, how would I attempt turning each square and its segment(s) of a line(s) into an average to be used later?
My first thought would be to give each line a specific colour from a function that scales {1,4} into a gradient from blue to red, then somehow using those values. But this is far beyond my skills in mathematica.
In the end I would like to turn this array of data of mine into a density plot similar to here.
pts, lve, and lho added updated lver which now has all square boundries
Thank you in advance.
pts = {{0, 1}, {8, 1}, {0, 1}, {8, 2}, {0, 1}, {8, 3}, {0, 1}, {8,
2}, {0, 1}, {8, 4}, {0, 1}, {8, 5}, {0, 1}, {8, 6}, {0, 1}, {8,
7}, {0, 1}, {8, 8}, {0, 2}, {8, 1}, {0, 2}, {8, 2}, {0, 2}, {8,
3}, {0, 2}, {8, 2}, {0, 2}, {8, 4}, {0, 2}, {8, 5}, {0, 2}, {8,
6}, {0, 2}, {8, 7}, {0, 2}, {8, 8}, {0, 3}, {8, 1}, {0, 3}, {8,
2}, {0, 3}, {8, 3}, {0, 3}, {8, 2}, {0, 3}, {8, 4}, {0, 2}, {8,
5}, {0, 3}, {8, 6}, {0, 3}, {8, 7}, {0, 3}, {8, 8}, {0, 4}, {8,
1}, {0, 4}, {8, 2}, {0, 4}, {8, 3}, {0, 4}, {8, 2}, {0, 4}, {8,
4}, {0, 4}, {8, 5}, {0, 4}, {8, 6}, {0, 4}, {8, 7}, {0, 4}, {8,
8}, {0, 5}, {8, 1}, {0, 5}, {8, 2}, {0, 5}, {8, 3}, {0, 5}, {8,
2}, {0, 5}, {8, 4}, {0, 5}, {8, 5}, {0, 5}, {8, 6}, {0, 5}, {8,
7}, {0, 5}, {8, 8}, {0, 6}, {8, 1}, {0, 6}, {8, 2}, {0, 6}, {8,
3}, {0, 6}, {8, 2}, {0, 6}, {8, 4}, {0, 6}, {8, 5}, {0, 6}, {8,
6}, {0, 6}, {8, 7}, {0, 6}, {8, 8}, {0, 7}, {8, 1}, {0, 7}, {8,
2}, {0, 7}, {8, 3}, {0, 7}, {8, 2}, {0, 7}, {8, 4}, {0, 7}, {8,
5}, {0, 7}, {8, 6}, {0, 7}, {8, 7}, {0, 7}, {8, 8}, {0, 8}, {8,
1}, {0, 8}, {8, 2}, {0, 8}, {8, 3}, {0, 8}, {8, 2}, {0, 8}, {8,
4}, {0, 8}, {8, 5}, {0, 8}, {8, 6}, {0, 8}, {8, 7}, {0, 8}, {8, 8}};
lho = {Line[{{0, 0.5}, {9, 0.5}}], Line[{{0, 1.5}, {9, 1.5}}],
Line[{{0, 2.5}, {9, 2.5}}], Line[{{0, 3.5}, {9, 3.5}}],
Line[{{0, 4.5}, {9, 4.5}}], Line[{{0, 5.5}, {9, 5.5}}],
Line[{{0, 6.5}, {9, 6.5}}], Line[{{0, 7.5}, {9, 7.5}}],
Line[{{0, 8.5}, {9, 8.5}}]};
lver = {Line[{{0, 0}, {0, 9}}], Line[{{1, 0}, {1, 9}}],
Line[{{2, 0}, {2, 9}}], Line[{{3, 0}, {3, 9}}],
Line[{{4, 0}, {4, 9}}], Line[{{5, 0}, {5, 9}}],
Line[{{6, 0}, {6, 9}}], Line[{{7, 0}, {7, 9}}],
Line[{{8, 0}, {8, 9}}]};
pts
. $\endgroup$