Thank you very much Timothée. That works.
Manuel 2017-03-06 9:42 GMT-06:00 Timothée Giraud <timothee.gir...@cnrs.fr>: > Hi, > > I understand you find a solution via hextess from spatstat. > > However, this is a solution with spsample from sp. > > Actually, the cellsize argument of spsample defines the distance between > the center of consecutives hexagons. > So it is the length of 2 medians of one of the 6 equilateral triangles > composing the hexagon. > > You can obtain the correct cellsize with: > - the formula that calculates the median length for a given equilateral > triangle length size, > - the formula that calculate the area of an hexagon with a given side > length. > > > library(sp) > data(meuse.grid) > gridded(meuse.grid) = ~x+y > plot(meuse.grid) > > # targeted area in meters > A <- 10000 > # Corresponding cellsize : > CS <- 2 * sqrt(A/((3*sqrt(3)/2))) * sqrt(3)/2 > > # hexagons > HexPts <-spsample(x = meuse.grid, type = "hexagonal", cellsize = CS) > HexPols <- HexPoints2SpatialPolygons(HexPts) > > plot(HexPols, add=TRUE) > > # check > rgeos::gArea(HexPols, byid = T)[1:10] > > > > > Since you asked me about getGridLayer via PM, this function of the > cartography package uses spsample with its cellsize argument, maybe I > should add a "targeted area" argument... > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- *Manuel Spínola, Ph.D.* Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA mspin...@una.cr <mspin...@una.ac.cr> mspinol...@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@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo