[OSGeo Africa] Split a polygon into smaller parts based on percentage values
jcstay123 at gmail.com
Tue Jun 30 02:13:57 PDT 2015
I need to automatically split polygons based on a percentage value of the
For example, if I have a polygon with a size of 100 ha, I want to split it
so that I have two polygons one that is 25ha (25% of the size of the
original) and another that is 75ha (75% of the size of the original).
The split can be done from any direction as long as the polygon is split in
the the right sized parts.
I have found an SQL script , working in PostGIS of course, that is suppose
to split a polygon in to two equal parts, but I'm having some trouble
modifying it to slits based on the percentage values. The script is below.
Will it even be possible to use this to do what I want?
Can anyone help,
-----script to split a polygon in to 2 equal parts
ref(the_geom, env) AS (
ST_Envelope(the_geom) As env,
ST_Area(The_geom)/2 As targ_area,
1000 As nit
T(n,overlap) AS (
VALUES (CAST(0 As Float),CAST(0 As Float))
SELECT n + nit, ST_Area(ST_Intersection(the_geom, ST_Translate(env, n+nit, 0)))
FROM T CROSS JOIN ref
WHERE ST_Area(ST_Intersection(the_geom, ST_Translate(env, n+nit, 0)))>
ORDER BY n DESC LIMIT 1)
ST_Difference(the_geom, ST_Translate(ref.env, n,0)) As geom_part1,
ST_Intersection(the_geom, ST_Translate(ref.env, n,0)) As geom_part2
FROM bi CROSS JOIN ref;
Thanks in advance!!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Africa