[SOLVED] Polygons with "holes"

Here you can report the problems encountered with the graphical functions (db.plot, vario.plot, ...)

[SOLVED] Polygons with "holes"

Postby niafall » Wed Jun 08, 2016 1:26 pm

Hello;

I am wondering if it is possible to define a polygon for a survey area with "hole(s)" to account for the presence of islands within that polygon?

Many thanks,
Niall
niafall
 
Posts: 21
Joined: Tue May 17, 2016 5:46 pm

Re: Polygons with "holes"

Postby Didier Renard » Mon Jun 20, 2016 8:12 pm

The Polygon is a complex class. It is defined in 2-D only. It is composed of a set of closed polygonal lines, called Polysets. This Polygon can be used for example to check if a some data information belongs to the polygon or not.
What about holes?

In order to create hole within a Polygon, it suffices to create a the outer part of the polygon and the inner part of the polygon and to join them with a two-way line.

The following example is the proof.
Let us imagine the following polygon whose vertex coordinates are given next:
0.1 0.1
0.7 0.5
0.1 0.9
0.1 0.5
0.2 0.5
0.2 0.4
0.4 0.4
0.4 0.6
0.2 0.6
0.2 0.5
0.1 0.5
0.1 0.1

We can check that the polygon defined above contains 12 vertices and corresponds to a square included within a triangle. The two-way line exists between vertices (0.1, 0.5) and (0.2, 0.5).

To check the shape and impact of the polygon, let us load it in the R object called poly.
We also create the data base db with 500 samples generated randomly in a [0,1] square. This high density is meant so as to ensure that there will be some samples contained in the square.

db = db.create(x1=runif(500),x2=runif(500))

We overlay the two objects:
plot(db)
plot(poly,add=T)

Image

We now use the polygon to reject the samples. Then the samples within the triangle are masked off, whereas those contained in the square (a hole in the triangle) are kept:

plot(db.polygon(db,poly,flag.out=TRUE)
plot(poly,add=T)

Image

Hope you are convinced.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: [SOLVED] Polygons with "holes"

Postby niafall » Mon Aug 08, 2016 2:39 pm

Thank you for this reply. I am currently processing my datasets to reproduce this approach.

A follow-up question: will the presence of the connecting lines affect the calculation of spatial indices in RGeostats? To clarify, will the presence of the connecting line affect the calculation of, for example, areas of influence?

Many thanks.
niafall
 
Posts: 21
Joined: Tue May 17, 2016 5:46 pm

Re: [SOLVED] Polygons with "holes"

Postby Didier Renard » Wed Aug 10, 2016 6:56 pm

Sorry but I do not understand what you mean by "connecting lines".
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: Polygons with "holes"

Postby niafall » Wed Aug 24, 2016 6:03 pm

Apologies, by connecting line, I meant the "two-way line" which you referred to (as emboldened in the quote, below).

Didier Renard wrote:In order to create hole within a Polygon, it suffices to create a the outer part of the polygon and the inner part of the polygon and to join them with a two-way line.
niafall
 
Posts: 21
Joined: Tue May 17, 2016 5:46 pm

Re: [SOLVED] Polygons with "holes"

Postby Didier Renard » Wed Aug 24, 2016 6:27 pm

Now that I understand what you mean by the connecting line, I can tell you that this two-way line WILL NOT affect
the calculations of the statistics, such as the calculation of area of influence.
As a matter of fact, this polygon is only used to known if a target is located inside or outside this polygon.
The order of the polygon edges is not considered ... hence my answer.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: [SOLVED] Polygons with "holes"

Postby niafall » Mon Aug 29, 2016 11:24 am

Many thanks for your help!
niafall
 
Posts: 21
Joined: Tue May 17, 2016 5:46 pm


Return to Graphical representation

Who is online

Users browsing this forum: No registered users and 1 guest

cron