If I have a polygonal geometry
gbase, like a street (a rectangular strip), and a reference geometry
gref, like a central line of
gbase. The question is what is the function (here named BestBuffer) that returns a geometry
gbest = BestBuffer(gbase, gref [,p])
that is the "best fit" for
gbase and can be generated from
gref by a ST_Buffer (optionally with a shape parametrized by
Formally this is a mathematical optimization problem:
gbest = ST_Buffer(gref,w,p)
w that supply
ST_Area(gbest) = ST_Area(gbase)
NOTE: I think
BestBuffer can be a "standard library" function (where is it? please show sources/references), not a external plugin, because the estimation checks are all standard OGC build-in functions.
BestBuffer when gref is a POINT
Illustrating by the trivial case, the buffer of point, that have exact solution:
is the same as "fit a polygon to a square of equal area" (or a circle).
gbase a (blue) island,
gref is only a point,
gref=ST_Centroid(gbase), or another position, and the parameter N, that can be 1 for square and 8 for circle.
gbest_square = bestBuffer(gbase,ST_Centroid(gbase),1); gbest_circle = bestBuffer(gbase,anotherpoint,8);
You can approximate
gbest without change original area.
BestBuffer when gref is a LINE
Illustrating with the Massachusetts avenue,
gbase, a polygon of a street,
gref a (blue) center line in it, and the choice of shape (no endcaps)
is a rectangle (
gbest). It is the "best buffer about
gref" for Massachusetts avenue, filling the same area as
BestBuffer when gref is a POLYGON
In the above illustration, the blue polygon represents a island with your beach, as
gref the same island without the beach.
gbest0 is the "best buffer" for
gref a (gray). Can be rendered as
ST_Difference(gbase,gref), that represent beachs.
gbest0=bestBuffer(gbase,gref), but we want to render as (
gbest = ST_Difference(gbest0,gref)
The goal of the buffer of
gref is to generate the "beach geometry", even if
gbest not generates an exact
gbase-gref geometry: it is a good approximation and have uniform width w, the average width of
gbase-gref (w is mean beach width).
Fit the "best curve" about a set of points in an XY chart is a classical statiscal problem,
have classical solutions, and have a lot of tools for it.
Similarly the "best curve about another curve" is usual when the "best" is a simple one,
like a straight line, a parabola, etc. To fit irregular/complex lines
Cubic spline lines are frequently used.
Where are the standard functions tools for "fit the best polygon in a GIS context"? Are there standard libraries? For generic statistical problems we have external packages that can be integrated with postgreSQL and PostGIS...
But for built-in functions:
ST_Buffer is a standard function, why not a function
BestBuffer in a complementary library?