Learn R Programming

spatialEco (version 0.1-5)

hexagons: Hexagons

Description

Create hexagon polygons

Usage

hexagons(x, res = 100, ...)

Arguments

x
sp SpatialDataFrame class object
res
Area of resulting hexagons
...
Additional arguments passed to spsample

Value

SpatialPolygonsDataFrame OBJECT

Examples

Run this code
require(sp)
  data(meuse)
    coordinates(meuse) <- ~x+y 

hex.polys <- hexagons(meuse, res=100)   
  plot(hex.polys)
    plot(meuse,pch=20,add=TRUE)

# Points intersecting hexagons  
hex.pts <- na.omit(over(meuse,hex.polys))
(hex.pts <- data.frame(PTID=rownames(hex.pts), hex.pts)) 

Run the code above in your browser using DataLab