[R-sig-Geo] Create circular polygon of certain radius in R

Giacomo May Giacomo_May94 at gmx.de
Wed Jun 8 13:26:39 CEST 2016


Hi,
I have a raster, which is projected into "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0". Now I would like to create a circular Polygon with a radius of 300 meters around a cell of my choice. I know about the function "spCircle()" in the package "sampSurf" and I heard that this should somehow be possibleusing the "gBuffer"-function from  the "rgeos"-package, but I don't know exactly how to use it.
I have tried achieving this with the following piece of code (altdata is the raster I am using):

coords <- xyFromCell(altdata,12703)
proj <- altdata at crs@projargs
coords_sp <- SpatialPoints(coords,CRS(proj))
polygon <- gBuffer(coords_sp,width=300)

But this returns the following warning message:

Warning message:

In gBuffer(coords_sp, width = 300) :
  Spatial object is not projected; GEOS expects planar coordinates

If anyone could help me with this I would be deeply grateful.
Best regards,
Giacomo May



More information about the R-sig-Geo mailing list