[postgis-users] Split polygons based on polygons' area

Jibran Khan jibran at envs.au.dk
Sun Jun 17 03:10:56 PDT 2018


Hello everyone,

I need some help in terms of splitting polygons based on the polygon area. I am using PostgreSQL 9.5.12/PostGIS 2.3 on Windows 10 (x64). I have two tables i.e. polygon (poly) and points (pts) in my Postgres db. Some of the polygons contain points inside them while, some do not (sample scenario below):

[cid:image001.png at 01D40632.134FDF00]

The following query:

/*Start of query*/
Select
    a.gid poly_id, count(b.geom) pt_cnt,
    st_area(a.geom)::int poly_area
FROM
    poly a
LEFT JOIN
    pts b
ON st_contains(a.geom, b.geom)
GROUP BY a.gid
Order by a.gid;
/*End of query*/

Returns the area of polygons (from left to right) as 1079, 744, 340 square-meter, respectively. I need to split these polygons' geometry based on the area i.e. if area is above 100 meter-square, then each polygon needs to be divided/split into "approximate equal" parts (assuming that majority of the polygons are straightforward like above). The division does not have to be "strictly" equal. Does anyone know or have any idea how this can be achieved?

Side Notes:


*         I earlier posted this question here at GIS SE<https://gis.stackexchange.com/questions/286184/postgis-how-do-i-split-polygon-in-equal-parts-based-on-polygon-area>

*         Also, came across this<https://gis.stackexchange.com/questions/239801/how-can-i-split-a-polygon-into-two-equal-parts-along-a-n-s-axis> relevant question but I guess my problem is different

Any help or idea(s) would be highly appreciated.

Best,
/Jibran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180617/f522a796/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 11557 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180617/f522a796/attachment.png>


More information about the postgis-users mailing list