Voronezh tessellation in Python

Node Assignment Task

enter image description here

The problem I want to solve is the tessellation of the map given by the blue nodes (source nodes) as the given input points. As soon as I can do this, I would like to see how many black nodes (demand nodes) fall inside each cell and assign it to the blue Node associated with this cell.

I would like to know if there is an easier way to do this without using Fortune Algorithm.I came across this function under Mahotas called Mahotas.segmentation.gvoronoi (image) source . But I'm not sure that this will solve my problem.

, , , ( ). , . .

+5
6

Voronoi:

k-d . node k-d, node , node.

k-d, http://code.google.com/p/python-kdtree/, .

+7

. , node .

, :

def distance(a, b):
    return sum((xa - xb) ** 2 for (xa, xb) in zip(a, b))

def clusters(sources, demands):
    result = dict((source, []) for source in sources)
    for demand in demands:
        nearest = min(sources, key=lambda s: distance(s, demand))
        result[nearest].append(demand)
    return result

, , node, .

, !

+1

Mathematica. ! (, , Python, ...)

pts3 = RandomReal[1, {50, 3}];
ListDensityPlot[pts3, 
    InterpolationOrder -> 0, ColorFunction -> "SouthwestColors", Mesh -> All]

          Voronoi Diagram

+1
+1

, Fortune. , , , script , .

script, PyPi Pytess. , pytess.voronoi(), , voronoi. "--", http://geospatialpython.com/2011/08/point-in-polygon-2-on-line.html.

enter image description here

0

All Articles