So, I came across this relevant question, but I think my problem is a bit different.
I have two tables i.e. polygon poly and points pts in my Postgres db. I am on Windows 10 (x64) based machine and using PostgreSQL 9.5.12/PostGIS 2.3. Some of the polygons contain points inside them while, some do not. The sample scenario is given as follows:
For each poly, the following query computes the area and counts number of pts inside polygon.
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;
The area of the polygons (from left to right) is 1079, 744, 340 meter-square respectively. Now, I would like 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. Can somebody suggest me a workaround to fix the issue?
UPDATE
Here, is another example of the polygons in my data. I am aware that there can be much more complex examples (e.g. irregular polygons). In that case, I think exceptions can be added.




ST_ApproximateMedialAxis(you need postgis_sfcgal extension); you'd need to extend the resulting line usingST_ClosestPointfrom it's start/end points to the polygons boundary and split it with that line as blade. might work, sry I can't get into detail right now. – geozelot Jun 13 '18 at 17:46