[R] divide polygon shapefile into 3 equal areas
boris.steipe at utoronto.ca
Mon Feb 29 19:14:24 CET 2016
Sounds like a fun little bit of code to write:
- write a function that will return the area of a slice as a function of a parameter X that can vary between some bounds on your shape: left to right, or top to bottom etc. E.g. if you want to slice vertically, this could be the area of the part of your polygon between the leftmost point and a vertical line at X. (Adapt from here perhaps: https://stat.ethz.ch/pipermail/r-sig-geo/2015-July/023168.html)
- find the roots of that function for f(X, shape) - 1/3 * totalArea and f(X, shape) - 2/3 * totalArea
On Feb 29, 2016, at 12:57 PM, Shane Carey <careyshan at gmail.com> wrote:
> ok thanks!!
> I would like to slice it vertically and have 3 distinct areas of equal
> area. So I need to chop it up into 3 areas of equal size essentially.
> There is no tool to do it in QGIS!!
> On Mon, Feb 29, 2016 at 5:51 PM, Barry Rowlingson <
> b.rowlingson at lancaster.ac.uk> wrote:
>> On Mon, Feb 29, 2016 at 5:37 PM, Shane Carey <careyshan at gmail.com> wrote:
>>> Is it possible to divide a polygon into 3 equal areas using R?
>> Yes, in an infinite number of ways. Want to narrow it down?
>> Specifically, you could slice it vertically, horizontally, or at any
>> angle between. You could chop it into squares and reassign them (did
>> you want **contiguous** areas?). You could choose a point and three
>> radii angles that divide the polygon into 3 equal areas in an infinite
>> number of ways.
>> The rgeos package will help you chop polygons up, and then uniroot
>> can find the coordinates of lines or radii of angles that chop the
>> polygon first into 1/3 & 2/3 then chop the 2/3 into 1/2 and 1/2,
>> giving you three equal pieces.
>>> I cant seem to be able to do it in QGIS.
>> If it can be done in R it can be done in Python and then it can be
>> done in QGIS...
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help