Learn R Programming

simba (version 0.3-4)

hexgrid: Produces the nodes of an equidistant grid.

Description

Given the coordinates of a starting point (left upper point of the grid), the function produces the nodes of an equidistant grid. Extent and distance between plots can be specified.

Usage

hexgrid(x, y, r = 100, nro = 10, nco = 20)

Arguments

x
x-value of the starting point. Defaults to 0.
y
y-value of the starting point. Defaults to 0.
r
Distance between nodes. Defaults to 100.
nro
Number of rows in the grid. Defaults to 10
nco
Number of columns in the grid. Defaults to 20. They are doubled (see the grid) compared to the rows. That's why 2*nro produces a quadratic grid.

Value

  • Returns a data.frame giving informations on the produced point/unit/plot locations with the following columns:
  • ROWNumber of row in the grid to which the point/unit/plot belongs.
  • COLNumber of column in the grid to which the point/unit/plot belongs.
  • Xx-coordinate of the point.
  • Yy-coordinate of the point.

encoding

UTF-8

Details

If the overall shape of the grid is not square, the user has to delete by hand the superfluous units. Might get more flexible in future versions.

References

http://homepage.mac.com/terhorab/gerald/downloads/whyhexaagons.pdf

See Also

spsample

Examples

Run this code
## produces a grid with r=400:    
test.grd <- hexgrid(456000, 7356700, r=400)
## for plotting the following is recommended as it preserves 
## real positions:
library(geoR)
points.geodata(coords=test.grd[,3:4], data=rnorm(nrow(test.grd)))

Run the code above in your browser using DataLab