map.lines: Add lines and polygons to climatological maps

View source: R/spatialPlot.R

map.linesR Documentation

Add lines and polygons to climatological maps

Description

Draws user-defined lines or polygons on top of climatological maps.

Usage

map.lines(lonLim = NULL, latLim = NULL, coords = NULL, ...)

Arguments

lonLim

A numeric vector of length 2, with minimum and maximum longitude coordinates (in grid units), of the rectangle to be drawn.

latLim

Same as lonLim, but for the selection of the latitudinal range.

coords

Optional. 2-column numeric matrix with vertex coordinates (1 point by row). Note that row order matters in order to define the drawing direction. Also bear in mind that first point (row) should equal last coordinates (row) in the case of closed polygonal areas.

...

Further optional style arguments (see the examples).

Details

The function internally transforms the inputs into Line class objects, so the displayed outputs are not actually polygons in a formal sense (they can not be filled, for instance). The purpose of the function is just to highlight specific areas within climatological maps (typically rectangular windows, but any other shapes like for instance storm tracks can be flexibly specified using coords).

Value

A list with a SpatialLines object, along with optional style arguments like col, lty, lwd etc., to be passed to the sp.layout argument in spatialPlot

Author(s)

J Bedia

See Also

spatialPlot, to which its output is passed. map.stippling, for further map customizations.

Examples


require(climate4R.datasets)
require(transformeR)
data("CFS_Iberia_tas")
# Define a rectangular window centered on the Iberian Peninsula
iberia <- map.lines(lonLim = c(-10,3.5), latLim = c(36,43))
spatialPlot(climatology(CFS_Iberia_tas), backdrop.theme = "coastline",
                sp.layout = list(iberia))

# Some customization options (awful, yes, but just for illustration):
iberia <- map.lines(lonLim = c(-10,3.5), latLim = c(36,44),
                    lwd = 3, # line width
                    col = "purple", # line color
                    lty = 2) # line type
spatialPlot(climatology(CFS_Iberia_tas, by.member = FALSE), backdrop.theme = "coastline",
                sp.layout = list(iberia))

# Another window over the Alps
alps <- map.lines(lonLim = c(4,16), latLim = c(45,49),
                  lwd = 3,
                  col = "red") 
spatialPlot(climatology(CFS_Iberia_tas, by.member = FALSE), backdrop.theme = "coastline",
                sp.layout = list(iberia, alps))


# Adding a line (real data of a storm-track imported from a csv file)
# Source: http://www.europeanwindstorms.org/

# Requires the target server to be operative...
dat <- url("http://www.europeanwindstorms.org/repository/Jeanette/Jeanette_track.csv")
custom.coords <- read.csv(dat, header = FALSE)[ ,5:4]
storm <- map.lines(coords = custom.coords,
                   lwd = 2,
                   col = "purple",
                   lty = 3) 
spatialPlot(climatology(CFS_Iberia_tas, by.member = FALSE), backdrop.theme = "coastline",
            ylim = c(35, 56), xlim = c(-10, 12),
            sp.layout = list(storm), # Add storm track
            scales = list(draw = TRUE)) # Add coordinate axes


SantanderMetGroup/visualizeR documentation built on Oct. 28, 2023, 6:11 a.m.