<div dir="ltr"><div><div>I was just looking at that code and trying to wrap my head around the rationale. Why a diagonal seed?<br></div><br></div><div>A grid would indeed solve my example but I have more irregular input data. <br></div>Would a quick & dirty solution be to spread K points randomly in the convex-hull of the the input set?<br><div><div><div><br></div>Your proposed strategy looks much more stable than the current and as far as I can grasp it would give denser seeding where there is higher density of geometries. I wonder though why it wouldn't be enough to just randomly pick points from the input set, apart from having a different outcome every time. <br></div><div><br></div><div>Tom<br></div><div><div><br>On Thu, Dec 28, 2017 at 10:47 PM, Darafei "Komяpa" Praliaskouski <span dir="ltr"><<a href="mailto:me@komzpa.net" target="_blank">me@komzpa.net</a>></span> wrote:<br><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div><div>Tom, the line of code that does the diagonal seeding is this:</div></div><div><a href="https://github.com/postgis/postgis/blob/svn-trunk/liblwgeom/lwkmeans.c#L187" target="_blank">https://github.com/postgis/<wbr>postgis/blob/svn-trunk/<wbr>liblwgeom/lwkmeans.c#L187</a> <br></div><div>At the very least to fix your case it may need to seed in a grid, so you need to make it two loops for row and column and estimate range for them from min/max height and width.</div></div><br></blockquote></div></div></div></div></div></div></div>