Learn R Programming

cartography (version 1.4.1)

getGridLayer: Build a Regular Grid Layer

Description

Build a regular grid based on a SpatialPolygonsDataFrame. Provide also a table of surface intersections.

Usage

getGridLayer(spdf, cellsize, type = "regular", spdfid = NULL)

Arguments

spdf
a SpatialPolygonsDataFrame.
cellsize
output cell size, in map units.
type
shape of the cell, "regular" for squares, "hexagonal" for hexagons.
spdfid
identifier field in spdf, default to the first column of the spdf data frame. (optional)

Value

A list is returned. The list contains "spdf": a SpatialPolygonsDataFrame of a regular grid and "df": a data frame of surface intersection. df fields are id_cell: ids of the grid; id_geo: ids of the spdf and area_pct: share of the area of the polygon in the cell (a value of 55 means that 55% of the spdf unit is within the cell).

See Also

getGridData

Examples

Run this code
## Not run: 
# data(nuts2006)
# # Get a grid layer
# mygrid <- getGridLayer(spdf = nuts2.spdf, cellsize = 200000)
# # Plot the grid
# plot(mygrid$spdf)
# head(mygrid$df)
#        ## End(Not run)

Run the code above in your browser using DataLab