Learn R Programming

opentraj (version 1.0)

PlotTrajFreq:

Plot Trajectory Frequency

Description

This function is designed to display a trajectory frequency map that was output by function RasterizeTraj.

Usage

PlotTrajFreq(spGridDf, background = T, overlay = NA, overlay.color = "white", pdf = F, file.name = "output", ...)

Arguments

spGridDf
SpatialGridDataFrame Object obtained by the convertion of the raster Object output by the RasterizeTraj function.
background
Boolean: Indicates whether or not the Canadian's background map should be displayed.
overlay
[Optional] If defined, it takes a SpatialPolygonsDataFrame as input and plots it over the spGridDf.
overlay.color
String. sets the Polygons' color defined by the overlay argument e.g. "blue"
pdf
Defines whether or not the output map should be saved in a pdf file.
file.name
String: If the argument pdf is True, this argument defined the name of the output file.
...
Further arguments to be passed to the generic function plot.

Value

Trajectory Frequency Map

Details

Since the function RasterizeTraj outputs a RasterLayer object, this Object must be converted to a SpatialGridDataFrame Object using the as(rasterObject, "SpatialGridDataFrame") for example.

See Also

RasterizeTraj

Examples

Run this code
  library(raster)
    
  crs <- "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"
  air.traj.lines <- Df2SpLines(air.traj, crs)
  raster.lines <- RasterizeTraj(air.traj.lines, reduce=TRUE, resolution=15000, parallel=FALSE)
    
  r.max.value <- maxValue(raster.lines)
  v <- getValues(raster.lines)
  v <- v / r.max.value
  r <- setValues(raster.lines, v)
    
  ## convert raster object to SparialGridDataFrame Object
  r1 <- as(r, "SpatialGridDataFrame")
    
  PlotTrajFreq(r1, background = TRUE, main="Title", pdf=FALSE)

Run the code above in your browser using DataLab