Learn R Programming

sensors4plumes (version 0.9.3)

polygrid2grid: Coerce SpatialPolygridDataFrame into SpatialGridDataFrame and geoTiff file

Description

Coerces SpatialPolygridDataFrame into SpatialGridDataFrame by copying the data to all associated grid cells. It may write the result to a geoTiff file.

Usage

polygrid2grid(obj, zcol = NA, returnSGDF = TRUE, geoTiffPath)

Arguments

obj

SpatialPolygridDataFrame-class

zcol

names or numbers of the data columns to be used

returnSGDF

if the generated SpatialGridDataFrame is to be returned

geoTiffPath

filename where to save the result as geoTiff (without suffix, '.tif' is added automatically); if missing, no geoTiff is generated

Value

A SpatialGridDataFrame with the same values assigned as in the SpatialPolygridDataFrame by copying the data to all associated grid cells. If returnSGDF = FALSE it returns TRUE.

Details

The main reason to turn a SpatialPolygridDataFrame into a SpatialGridDataFrame is for plotting. It can make sense to generate a (multilayer) geoTiff instead of returning the transformed data into the workspace.

Examples

Run this code
# NOT RUN {
data(SPolygridDF)

# return SpatialGridDataFrame
SGridDF1 = polygrid2grid(SPolygridDF, zcol = "b")

# generate geoTiff 
polygrid2grid(SPolygridDF, returnSGDF = FALSE, 
              geoTiffPath = "SPolygridDF1")

# plot SpatialGridDataFrame
spplot(SGridDF1)

# view geoTiff with functions from 'raster' and delete it
SGridDF2 = brick("SPolygridDF1.tif")
plot(SGridDF2)
rm(SGridDF2)
file.remove("SPolygridDF1.tif")
# }

Run the code above in your browser using DataLab