Learn R Programming

cartography (version 1.2)

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, spdfid = NULL)

Arguments

spdf
a SpatialPolygonsDataFrame.
cellsize
output cell size, in map units.
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
data(nuts2006)
# Get a grid layer
mygrid <- getGridLayer(spdf = nuts2.spdf, cellsize = 200000)
# Plot the grid
plot(mygrid$spdf)
head(mygrid$df)

Run the code above in your browser using DataLab