related:
Random Geometry Generation with PostGIS ( by Paul Ramsey, Sep 11, 2023 )
https://www.crunchydata.com/blog/random-geometry-generation-with-postgis
Maybe we could add a few new "ST_generate*" functions to PostGIS:
- ST_GenerateLine(n_vertices INTEGER, bounding_geometry GEOMETRY)
-
You need to do
CREATE EXTENSION postgis_sfcgal;
It’s not part of the postgis extension. If you don’t have that extension, then
you can’t use this function.
You next best bet is using ST_ConcaveHull
https://postgis.net/docs/ST_ConcaveHull.html
From: postgis-users On
Hi, Regina,
It did not work.
ERROR: function st_optimalalphashape(geometry) does not exist LINE 1:
SELECT min(gs) , max(gs), st_optimalalphashape(st_collect(S... ^ HINT: No
function matches the given name and argument types. You might need to add
explicit type casts. SQL state: 42883 Character:
You are using the wrong version of ST_Collect. You want to use the aggregate
form. You are using the two point form -
https://postgis.net/docs/en/ST_Collect.html
Also when you aggregate, you can’t include the gs in there.
Try:
SELECT min(gs) , max(gs),
I tested St_optimalphashape and it does not work.
select gs,
st_optimalalphashape(st_collect(ST_MakePoint(random()*10,random()*10),ST_MakePoint(random()*10,random()*10))::geometry)
from generate_series(1,100) gs;
Example given here does not work either.
ST_OptimalAlphaShape (postgis.net)
David,
The example query in the docs, is as simple as it gets. It’s a self-contained
example you can just run, but it does return a multipoint and I realize now the
docs don’t make it clear ST_GeneratePoints returns a single geometry that is a
multipoint.
IF you want individual points,
The simplicity is beautiful. Any simple script to do so? I think that
will be an useful addition.
Regards,
David
On Friday, 8 September 2023, Regina Obe wrote:
> David,
>
>
>
> For this are you needing to generate random points from a line or polygon
> or are you trying to generate random
David,
For this are you needing to generate random points from a line or polygon or
are you trying to generate random polygons, lines, and points?
If you need to generate random points from a polygon:
Use ST_GeneratePoints: https://postgis.net/docs/en/ST_GeneratePoints.html
Note
Is a simple way to do this?
Regards,
David
___
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users