[R-sig-Geo] Create circular polygon of certain radius in R
Bede-Fazekas Ákos
bfalevlist at gmail.com
Wed Jun 8 17:29:26 CEST 2016
Hi Giacomo,
you should use a projection that is planar (azimuthal). Select one
planar projection, use spTransform() from sp package to transform your
data to the selected planar projection, and then everything will works fine.
Some links:
https://en.wikipedia.org/wiki/Map_projection#Azimuthal_.28projections_onto_a_plane.29
http://spatialreference.org/ref/epsg/
http://www.inside-r.org/packages/cran/rgdal/docs/spTransform
HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences
2016.06.08. 13:26 keltezéssel, Giacomo May írta:
> 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
>
> _______________________________________________
> 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