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

Roger Bivand Roger.Bivand at nhh.no
Wed Jun 8 18:04:24 CEST 2016


On Wed, 8 Jun 2016, Bede-Fazekas Ákos wrote:

> 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.

Right, this is what rgeos is warning about. I'm afraid, though, that since 
the raster is in geographical coordinates, that may entail transforming 
the circle back from planar coordinates (+units=m) to geographical 
coordinates, and then the number of border line segments may also matter. 
Had the workflow been in projected coordinates from an earlier point, this 
would be simpler.

Roger

> 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
>> 
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412


More information about the R-sig-Geo mailing list