[R-sig-Geo] Move all the polygon vertices

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Feb 9 18:57:08 CET 2015


You need the sp package for making spatial polygons objects and the
rgeos package for doing buffering:

library(sp)
# convert your `r1` into a SpatialPolygons object:

p = SpatialPolygons(list(Polygons(list(Polygon(r1)),ID=1)))
plot(p)

library(rgeos)
# use a negative buffer for inside buffers:
bp = gBuffer(p, width=-30)
plot(bp, add=TRUE)

That should do it...

Barry



On Mon, Feb 9, 2015 at 5:09 PM, Alexandre Santos
<alexandresantosbr at yahoo.com.br> wrote:
> Dear Members,
>       I created a polygon (c1) below with the vertices data in UTMand I would like to know, if there are any function to move all the vertice in 30 metersinside with the reduction of my polygon area?
>
> #Polygon coordinates --------------------------------------------------------------x.coords1<-c(371299.9,    371266.4,    371205.6,    371111.8, 371047.6,    371018.2,    371014.0,              371009.3,    370983.1,    370919.7,    370853.6, 370785.6,    370748.8,    370711.8,              370687.8,    370696.4,    370785.9,    370885.5, 371035.8,    371148.1,    371205.2,              371231.7,    371236.5,    371240.3,    371285.8, 371326.5,    371397.2,    371417.1,              371432.9,    371445.0,    371455.7,    371466.4, 371476.6,    371502.6,    371536.0,              371550.0,    371546.8,    371528.3,    371470.0, 371393.3,    371299.9,    371299.9)
> y.coords1<-c(8246589,    8246560,    8246508,    8246428, 8246373,    8246349,    8246348,             8246352,    8246385,    8246465,    8246551, 8246638,    8246685,    8246732,             8246764,    8246771,    8246846,    8246932, 8247062,    8247160,    8247209,             8247230,    8247224,    8247221,    8247160, 8247107,    8247016,    8246991,             8246967,    8246939,    8246914,    8246892, 8246875,    8246846,    8246821,             8246809,    8246802,    8246785,    8246735, 8246669,    8246589,    8246589)
>
> # Create a polygont05<-unique(data.frame(x=rev(x.coords1),y=rev(y.coords1)))c1 = cbind (t05$x, t05$y)r1 = rbind (c1, c1[1, ])  # juntaplot(c1) ##Plot the polygonpolygon(c1)## Countour#
> Thanks in advance,
> Alexandre
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list