[R-sig-Geo] Making an hexagonal grid using spsample
Tim Keitt
tkeitt at utexas.edu
Mon Mar 6 21:18:20 CET 2017
http://www.keittlab.org/
On Fri, Mar 3, 2017 at 1:03 PM, Manuel Spínola <mspinola10 at gmail.com> wrote:
> Dear list members,
>
> I am trying to make an spatial hexagonal grid in R using the spsample
> function. I would like hexagons of 1 ha = 10000 sq meters.
>
>
> First I used a cell size of 62.04 m as the side of the hexagon.
>
> data(meuse.grid)
> gridded(meuse.grid) = ~x + y
> proj4string(meuse.grid) <- CRS("+init=epsg:28992")
> xx <- spsample(meuse.grid, type = "hexagonal", cellsize = 62.04)
> xx <- HexPoints2SpatialPolygons(xx)
> rgeos::gArea(xx, byid=TRUE)
>
> It gave me an area per hexagon = 3333.299
>
> Second I used a cell size of 62.04 * 2 = 124.08 m as the long diagonal of
> the hexagon
>
> data(meuse.grid)
> gridded(meuse.grid) = ~x + y
> proj4string(meuse.grid) <- CRS("+init=epsg:28992")
> xx <- spsample(meuse.grid, type = "hexagonal", cellsize = 62.04*2)
> xx <- HexPoints2SpatialPolygons(xx)
> rgeos::gArea(xx, byid=TRUE)
>
> It gave me an area per hexagon = 13333.19
>
> Both results are wrong, because I was expecting close to 10000.
>
> How can I make a spatial grid of 1 ha (or other size) in R?
>
You might search the list. I posted R code a long time ago that builds a
hexagonal tessellation over a rectangle. I think Edzer used that to add the
hexagonal option to spsample.
THK
>
> Manuel
>
> --
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.cr <mspinola at una.ac.cr>
> mspinola10 at 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 at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list