Using external scripts to embed other libraries in order to calculate a Voronoi diagram – advanced
While the previous recipe works fine for typical cases, faster approaches are available. Rather than functions built into Python, we can leverage Python libraries that are wrappers for compiled C++ code, resulting in an order-of-magnitude improvement in speed. The price we pay is writing a function to embed the faster functionality. This price is a one-time cost of thought and consideration and well worth the pay off for faster computation that will be, in some cases, orders-of-magnitude faster than our native Python function.
In addition, the pattern we will be using, that is, passing data from PostGIS to an external package and returning information from that package, is useful for doing a variety of processing that is not available in PostGIS or PostgreSQL natively, but may otherwise be available in an external library or program. In other words, once PostGIS has a native Voronoi function...