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

Rolf Turner r.turner at auckland.ac.nz
Sat Mar 4 02:31:29 CET 2017


On 04/03/17 08:38, Marcelino de la Cruz Rot wrote:
> 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)

Marcelino,

Actually I said hexagons of area *42* ha should have side length equal 
to 402.0673 metres.

Moreover the Chorley data set has units of *kilometres* not hectometres,
so that should be s <- 0.4020673.  Or, to avoid just a touch of 
round-off error, s <- sqrt(2*0.42)/3^0.75.

Note that if you then do

xxx <- hextess(W,s,trim=FALSE)
unique(sapply(tiles(xxx),area.owin))

you get 0.42 --- i.e. 0.42 square kilometres, or 42 hectares.

cheers,

Rolf

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-sig-Geo mailing list