[R-sig-Geo] Making an hexagonal grid using spsample

Marcelino de la Cruz Rot marcelino.delacruz at urjc.es
Fri Mar 3 20:38:24 CET 2017


Hi  Manuel,

I do answer to the question "How can I make a spatial grid of 1 ha (or 
other size) in R?"

You can use function hextess in spatstat

library(spatstat)

# some arbitrary area, with coordinates in hectometres
  W <- Window(chorley)

# As Rolf said, hexagons of 1ha should have side of 402.0673 metres, so, 
in hectometres:

s <- 4.020673

plot(hextess(W, s))
plot(hexgrid(W, s), add=TRUE)


Cheers,

Marcelino

El 03/03/2017 a las 20:03, Manuel Spínola escribió:
> 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?
>
> Manuel
>


-- 
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España



More information about the R-sig-Geo mailing list