[postgis-devel] ST_GeneratePoints randomness
Brent Wood
pcreso at yahoo.com
Fri Jan 18 12:44:34 PST 2019
Have one function with a seed...
The same seed generates the same set, using random() as the seed generates a different random selection each time, but recording the seed value provides reproducibility, which can be important.
Brent Wood
From: Martin Davis <mtnclimb at gmail.com>
To: PostGIS Development Discussion <postgis-devel at lists.osgeo.org>
Sent: Saturday, January 19, 2019 6:50 AM
Subject: Re: [postgis-devel] ST_GeneratePoints randomness
Perhaps there is a use case for both functions? One that generates a reproducible set of pseudo-random points, and one that generates a different set each time called.
If so, it sounds like the "really random" function would have to be a separate VOLATILE declaration.
On a related note, generating random points using a simple random function produces quite "clumpy" point sets. There's lots of approaches to creating more evenly spaced quasi-random pointsets, such as Halton points [1] or using a distance tolerance [2]. It might be nice to provide one or more of these as functions as well.
[1] https://lin-ear-th-inking.blogspot.com/2012/09/halton-sequences-at-last.html[2] https://lin-ear-th-inking.blogspot.com/2015/07/even-distribution-random-point-and.html
On Fri, Jan 18, 2019 at 5:51 AM Darafei "Komяpa" Praliaskouski <me at komzpa.net> wrote:
Hi Felix,
would you prefer the function to always return the same set of random points, or get the fact that it can return different set of points on invocations in different transactions documented?
I'm not sure treating it same as random() is a great idea, I use it more like "give me a point cloud that fills this polygon" converting it for usage in point-accepting functions, like calculating the median of the polygon. I'd prefer it cached like it is now for such cases.
What are you using your random geodata for?
On Wed, Jan 16, 2019 at 1:11 AM Felix Kunde <felix-kunde at gmx.de> wrote:
Hi list, I thought that this topic better belongs on this list.I'm trying to create some random spatial data using the ST_GeneratePoints functions. I wanted to reuse it also for lines and polygons but stumbled over the issue that multiple calls of the function in one transaction produce the same result. I tested different query constructs - even looping over a PL/pgSQL function - but no luck. So whereas: SELECT random() AS random_a, random() AS random_b; creates different results, this: SELECT
ST_AsText(ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry, 2)) AS random_a,
ST_AsText(ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry, 2)) AS random_b; will produce the same. There are workaround to generate random geodata, of course.Just wanted to point it out here and see, if you are aware of this. I couldn't found any ticket regarding this behaviour. Best, Felix
_______________________________________________
postgis-devel mailing list
postgis-devel at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20190118/4a314014/attachment.html>
More information about the postgis-devel
mailing list