[R-sig-Geo] [FORGED] circular spatial polygon

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Sep 13 09:01:41 CEST 2017


Your question is still a tiny bit imprecisely defined, since you haven't
said how you want this polygon to align to the axes. This function computes
the coordinates of an N-sided regular polygon centred at (x,y) of radius r,
of n sides, at angle theta:

ngon =
function(x,y,r,n,theta){
  phi = seq(theta, theta+2*pi, length=n+1)
  xc = x + r * sin(phi)
  yc = y + r * cos(phi)
  cbind(xc,yc)
}

Two possible solutions to your question are therefore:

 plot(ngon(673593.21, 9365367.08, 15, 8, 0), asp=1)
 plot(ngon(673593.21, 9365367.08, 15, 8, pi/8), asp=1)

although that only shows points, building some sort of spatial polygon
follows easily enough.

Creating points on a circle using trigonometry (sines and cosines) should
be in any introductory trigonometry book.

B



On Wed, Sep 13, 2017 at 2:30 AM, Loïc Dutrieux <loic.dutrieux at conabio.gob.mx
> wrote:

> This is also possible with rgeos
>
> library(sp)
> library(rgeos)
>
> x <- 673593.21
> y <- 673593.21
>
> sp0 <- SpatialPoints(coords = data.frame(x=x, y=y),
>                      proj4string = CRS('+proj=utm +zone=20 +south
> +ellps=WGS84 +datum=WGS84 +units=m +no_defs'))
> sp1 <- gBuffer(sp0, byid=TRUE, width = 15, quadsegs = 2)
> plot(sp1)
>
>
> Cheers,
> Loïc
>
> On 12/09/2017 16:57, Rolf Turner wrote:
> >
> > On 13/09/17 08:48, Kátia Emidio wrote:
> >
> >> Dear all,
> >> My question is how to create a circular spatial polygon, with 8 arcs
> >> of 45
> >> degrees, and radius measuring 15m. Having in the centre point the UTM
> >> coordinates, zone 20S.
> >>
> >> x= *673593.21*
> >> y= *673593.21*
> >
> > "Circular polygon" is a contradiction in terms.  If a shape is a polygon
> > then it is *not* a circle.  (Of course in real life we use polygons with
> > large numbers of sides to *approximate* circles.  But 8 is not large!)
> >
> > You can create an octagon with the required centre and radius using
> > *spatstat* via:
> >
> >     oct <- disc(radius=15,centre=c(673593.21,673593.21),npoly=8)
> >
> > Does that provide (at least a start on) what you want?
> >
> > cheers,
> >
> > Rolf Turner
> >
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list