[postgis-users] Sample - Points into Polygons

Darafei "Komяpa" Praliaskouski me at komzpa.net
Fri May 25 14:41:48 PDT 2018


I see two ways to address your problem.

First step, by area, calculate expected number of points in polygon.

Then, depending on quality/speed tradeoff,

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.

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.

сб, 26 мая 2018, 00:26 карыстальнік Vispo Leblanc <vispoleblanc at gmail.com>

> Hello PostGIS users,
> 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.
> 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.
> I draw the following diagram to explain:
> [image: image.png]
> Please let me know if you have any ideas or functions I can use to solve
> my problem.
> Thank you :-)
> Vispo
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180526/5a5cd920/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 56937 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180526/5a5cd920/attachment.png>

More information about the postgis-users mailing list