<div dir="ltr">Thanks for your support, I was able to make it work!<br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, May 25, 2018 at 4:01 PM Thijs van den Berg <<a href="mailto:thijs@sitmo.com">thijs@sitmo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Or associate each point with a grid cell id using scaling and rounding of coordinates cell_id=int(x/cell_width)+rn_cols*(y/cell_width). If it were a 3x3 tic tac toe grid you'd have 0,1,2,..,8.<div dir="auto"><br></div><div dir="auto">Then select distinct points on that grid cell id?</div></div><div class="gmail_extra"><br><div class="gmail_quote">Op 25 mei 2018 23:42 schreef "Darafei "Komяpa" Praliaskouski" <<a href="mailto:me@komzpa.net" target="_blank">me@komzpa.net</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">Hi,</div><div dir="auto"><br></div><div dir="auto">I see two ways to address your problem.</div><div dir="auto"><br></div><div dir="auto">First step, by area, calculate expected number of points in polygon.</div><div dir="auto"><br></div><div dir="auto">Then, depending on quality/speed tradeoff,</div><div dir="auto"><br></div><div dir="auto">fast: for each polygon you make ST_GeneratePoints, and for each point take 1 closest point using KNN query, then apply DISTINCT to filter duplicates.</div><div dir="auto"><br></div><div dir="auto">with some eyecandy guarantees: take KMeans of all the points in polygon with K you calculated. In each cluster, take ST_GeometricMedian. Take point from each cluster closest to cluster center.</div><div dir="auto"><br></div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">сб, 26 мая 2018, 00:26 карыстальнік Vispo Leblanc <<a href="mailto:vispoleblanc@gmail.com" target="_blank">vispoleblanc@gmail.com</a>> напісаў:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">Hello PostGIS users,<span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">I have one table with thousand of polygons and another one with million of points. I would like to select all the points that are within the polygons, BUT I just want a sample of the data. Let me explain.<span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">Let’s say I have a polygon of 1,000 square meter with 60 points, ideally I would like to take only 1 points. But if the polygon is 10,000 square meter with 600 points then ideally I would take only 10 points. Also, in a perfect world, I would only select a sample of points that are spread out enough to be representative of the polygons. Let’s take the 10,000 square meters polygon for example, I would only select 10 points that are everywhere in the polygon and not 10 points that are within 10 meters of each other’s.<span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">I draw the following diagram to explain:<span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p>

<div><img src="cid:ii_jhmh4yda0" alt="image.png" width="412" height="291"><br></div><div><br></div><div>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">Please let me know if you have any ideas or functions I can use to solve my problem.<span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif">Thank you :-)</p>

<br></div><div>Vispo</div><br></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" rel="noreferrer" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br></blockquote></div></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>