[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-geo
Subject:    Re: [R-sig-Geo] How to do square buffers around spatial points
From:       Manuel_Spínola <mspinola10 () gmail ! com>
Date:       2016-08-25 13:38:35
Message-ID: CABkCotQipAmQO57=0Nqd9XFzEYJuD9RuYtkE8XcdWdw7WAOaOg () mail ! gmail ! com
[Download RAW message or body]

Thank you very much for both answers.

Manuel

2016-08-25 7:36 GMT-06:00 Barry Rowlingson <b.rowlingson@lancaster.ac.uk>:

> Here's a one-liner:
>
> # for some SpatialPointsDataFrame `d`, and some half-width `w`, this
> produces a set of square SpatialPolygons
> # with square height and width equal to 2*w:
>
> polys = SpatialPolygons(apply(apply(coordinates(d),1,function(r){
> cbind(r+c(w,w),r+c(w,-w),r+c(-w,-w),r+c(-w,w),r+c(w,w))}),2,
> function(v){Polygons(list(Polygon(matrix(v,ncol=2,byrow=
> TRUE))),ID=runif(1))}))
>
>  > plot(polys)
>  > plot(d,add=TRUE)
>
> Barry
>
>
>
> On Thu, Aug 25, 2016 at 2:11 PM, Barry Rowlingson
> <b.rowlingson@lancaster.ac.uk> wrote:
> > 2016-08-25 13:01 GMT+01:00 Manuel Spínola <mspinola10@gmail.com>:
> >> Dear list members,
> >>
> >> Ho can I do square buffers around spatial points?
> >
> > Break it down:
> >
> > 1. For each point compute the coordinates of the four corners of the
> > square by adding half the width of your square.
> > 2. Construct a Polygon from those four points for each of your source
> points.
> > 3. Build a SpatialPolygons object from all your Polygons.
> >
> > How far can you get with it now?
> >
> > Barry
>



-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspinola@una.cr <mspinola@una.ac.cr>
mspinola10@gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic