[R] Convert one rectangle into two rectangles
Ebert,Timothy Aaron
tebert @end|ng |rom u||@edu
Wed Apr 27 19:22:22 CEST 2022
One thought was that these were farm fields in satellite images. I just had no clue why one would subdivide them. Maybe a training and testing portion of these polygons? At a few dozen meters the curvature might be negligible on a sufficiently large spheroid. If 45-55% split is approximate then go through the entire polygon area pixel by pixel and use rnorm() to generate a random value that puts the pixel in A if <0.4 and in B it >0.4. This has a better chance of working if the polygon is centered in the image so that curvature weighs equally.
For this post my thought was that it was either homework because the question was so simple, or it was not providing enough information to answer the real question. The generalized question is to divide an n-sided polygon mapped to the surface of a spheroid with semi-axes A, B, C into 45-55% split into two parts 45 and 55%. If multiple polygons were spread over the image and the image curvature was large relative to the image size I don't see how you could recover polygons close to the edge of the spheroid unless you knew beforehand the curvature at that point. Possibly in the most general sense the problem is unsolvable because angles near the horizon will be nearly straight lines.
Another part of asking questions is to provide enough detail that others may arrive at a creative answer. How about a mechanical solution. Print the polygon onto paper. Cut the polygon out. Cut the polygon in half. Weigh the halves to get actual split. Scan each piece in. You can print several copies and repeat until you get a 45-55 split as close as your equipment will measure. I have solved the problem as asked, though it did not involve R. I split the polygon problem solved or do I need to do something with the pieces?
I had posted a simple R solution, but was then asked if the solution would work for a trapezoid with 21 bottom and 18 top. My solution was not generalizable but the question was for a rectangle (four 90 degree angles and parallel opposite sides) with sides 18 and 200 meters.
You could draw polygons on a balloon using a sharpie marker (or similar). Photograph the balloon at different distances, and process the images. At least this way you have a system to test that part of the program. Correct pixel area for curvature, estimate area of polygon, and then figure out what it means to split the polygon. If the non-regular polygon is not evenly divisible 45-55 what happens to the remainder?
Is this problem better handled using GIS techniques?
Tim
-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Avi Gross via R-help
Sent: Wednesday, April 27, 2022 11:27 AM
To: r-help using r-project.org
Subject: Re: [R] Convert one rectangle into two rectangles
[External Email]
Just FYI, Jim, I was sent private mail by Javad that turns the problem aroundso not only are there no rectangles, but the problem is not 2-D. He is working with Spatial Polygons representing areas on the surface of a sphere (presumably Earth) and wants to subdivide them. This is a VERY different topic and there are packages and other references that might apply to his needs. I have no idea why the 60/40 split by area.
Yes, as a very simplified idea, I understand why he proposed dividing a rectangle proportionately but realistically what he is working with is a bit more like a trapezoid which is also bent into a third dimension.
So those of us wanting to help on the original problem can stop and, speaking for myself, I am going to approach many questions posed here more carefully to see if they are well-thought-out or are some kind of fishing expedition. And, since it has been made very clear multiple times that the scope of this forum is narrow and not meant to help with HW, and I have no idea how to verify it is not, ...
-----Original Message-----
From: Jim Lemon <drjimlemon using gmail.com>
To: javad bayat <j.bayat194 using gmail.com>; r-help mailing list <r-help using r-project.org>
Sent: Wed, Apr 27, 2022 5:59 am
Subject: Re: [R] Convert one rectangle into two rectangles
Hi javad,
Let's think about it a little. There are only two ways you can divide a rectangle into two other rectangles.
The dividing line must be straight and parallel to one side or the other or you won't get two rectangles.
If there are no other constraints, you can take your pick.
A E B
-------------------------------------
| | |
-------------------------------------
C F D
AE = CF = 0.45 * AB
Alternatively the same equation can be used on the shorter sides.
If you want to cut it across the length, you can do it with an abacus.
While the IrregLong package can produce an abacus plot, I was unable to find an R-based abacus.
For that I suggest:
https://urldefense.proofpoint.com/v2/url?u=https-3A__toytheater.com_abacus_&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7NHiO0K9V&s=Fz2RhXtevzROx9IOzX2dn3FYg972J9cnuWoWW7MqZBo&e=
Jim
On Wed, Apr 27, 2022 at 1:42 AM javad bayat <j.bayat194 using gmail.com> wrote:
>
> Dear R users;
> I want to convert a rectangle into 2 new rectangles. I have a
> rectangle (18 m * 200 m), and I want to subtract 45 percent of it's
> area as a new rectangle. Is it possible to do this in R?
> Sincerely.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
> man_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAs
> Rzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7N
> HiO0K9V&s=AZ_JuNx5fiOamGA0k4TSWI5sC8DZZdomay2LjrgyMtM&e=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeA
> sRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7
> NHiO0K9V&s=VPNX6IvYr7F4Vti-KkGsoS-sxBZHfX4T6JTrzo7_aOw&e=
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7NHiO0K9V&s=AZ_JuNx5fiOamGA0k4TSWI5sC8DZZdomay2LjrgyMtM&e=
PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7NHiO0K9V&s=VPNX6IvYr7F4Vti-KkGsoS-sxBZHfX4T6JTrzo7_aOw&e=
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7NHiO0K9V&s=AZ_JuNx5fiOamGA0k4TSWI5sC8DZZdomay2LjrgyMtM&e=
PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Tbmiv3MGuN8f7gYSHUOKBKkBAx5goWhCbuyiJMDVP2c3HV-_FfjZ8__7NHiO0K9V&s=VPNX6IvYr7F4Vti-KkGsoS-sxBZHfX4T6JTrzo7_aOw&e=
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list