Title: | Meridional and Parallel Lines for Maps |
---|---|
Description: | Create graticule lines and labels for maps. Control the creation of lines or tiles by setting their placement (at particular meridians and parallels) and extent (along parallels and meridians). Labels are created independently of lines. |
Authors: | Michael D. Sumner [aut, cre] |
Maintainer: | Michael D. Sumner <[email protected]> |
License: | GPL-3 |
Version: | 0.3.0 |
Built: | 2024-11-05 04:28:09 UTC |
Source: | https://github.com/hypertidy/graticule |
Specify the creation of lines along meridians by specifying their placement
at particular lons
(longitudes) and lats
(latitudes) and their extents
with xlim
(extent of parallel line in longitude) and ylim
(extent of meridional line in latitude).
graticule(lons, lats, nverts = NULL, xlim, ylim, proj = NULL, tiles = FALSE)
graticule(lons, lats, nverts = NULL, xlim, ylim, proj = NULL, tiles = FALSE)
lons |
longitudes for meridional lines |
lats |
latitudes for parallel lines |
nverts |
number of discrete vertices for each segment |
xlim |
maximum range of parallel lines |
ylim |
maximum range of meridional lines |
proj |
optional proj.4 string for output object |
tiles |
if |
Provide a valid PROJ.4 string to return the graticule lines in this projection. If this is not specified the graticule
lines are returned in their original longlat / WGS84.
All segments are discretized as _rhumb_lines_ at 'getOption("graticule.mindist")' metres, which
defaults to '5e4'.
The arguments xlim
, ylim
and nverts
are ignored if tiles
is TRUE
.
SpatialLines or SpatialPolygons object
graticule()
graticule()
Returns a set of points with labels, for plotting in conjuction with graticule
.
graticule_labels(lons, lats, xline, yline, proj = NULL)
graticule_labels(lons, lats, xline, yline, proj = NULL)
lons |
longitudes for meridional labels |
lats |
latitudes for parallel labels |
xline |
meridian/s for placement of parallel labels |
yline |
parallel/s for placement of meridian labels |
proj |
optional proj.4 string for output object |
SpatialPoints are returned in the projection of proj
if given, or longlat / WGS84.
SpatialPoints object with labels for downstream use
xx <- c(100, 120, 160, 180) yy <- c(-80,-70,-60, -50,-45, -30) prj <- "+proj=lcc +lon_0=150 +lat_0=-80 +lat_1=-85 +lat_2=-75 +ellps=WGS84" plot(graticule(lons = xx, lats = yy, proj = prj)) labs <- graticule_labels(lons = xx, lats = yy, xline = 100, yline = -80, proj = prj) op <- par(xpd = NA) text(labs, lab = parse(text = labs$lab), pos = c(2, 1)[labs$islon + 1], adj = 1.2) par(op)
xx <- c(100, 120, 160, 180) yy <- c(-80,-70,-60, -50,-45, -30) prj <- "+proj=lcc +lon_0=150 +lat_0=-80 +lat_1=-85 +lat_2=-75 +ellps=WGS84" plot(graticule(lons = xx, lats = yy, proj = prj)) labs <- graticule_labels(lons = xx, lats = yy, xline = 100, yline = -80, proj = prj) op <- par(xpd = NA) text(labs, lab = parse(text = labs$lab), pos = c(2, 1)[labs$islon + 1], adj = 1.2) par(op)
Use the coordinates of the input raster to generate coordinate rasters, these are then used in a contour plot.
lonlat( x, na.rm = FALSE, lon = FALSE, lat = FALSE, ..., plot = TRUE, add = TRUE )
lonlat( x, na.rm = FALSE, lon = FALSE, lat = FALSE, ..., plot = TRUE, add = TRUE )
x |
input raster |
na.rm |
logical, remove missing values from generated coordinates |
lon |
if TRUE, only longitude plotted |
lat |
if TRUE (and 'lon = FALSE') only latitude plotted |
... |
passed to [graphics::contour()] |
plot |
logical, plot the result |
add |
logical, add to current plot or instantiate one |
Plot is added to an existing plot by default.
RasterBrick of the longitude and latitude values, two layers
(invisibly) the raster (RasterBrick) object with longitude and latitude values of the input as two layers, otherwise this function used for side-effect (drawing on a plot)
plot(c(-180, 180), c(-90, 90)) lonlat(raster::raster()) p <- raster::projectExtent(raster::raster(), "+proj=igh") lonlat(p, add = FALSE) lonlat(p, levels = seq(-180, 180, by =15), add = FALSE) lonlat(p, levels = seq(-180, 180, by = 5), add = FALSE, lon = TRUE) lonlat(p, levels = seq(-180, 180, by = 15), add = TRUE, lat = TRUE)
plot(c(-180, 180), c(-90, 90)) lonlat(raster::raster()) p <- raster::projectExtent(raster::raster(), "+proj=igh") lonlat(p, add = FALSE) lonlat(p, levels = seq(-180, 180, by =15), add = FALSE) lonlat(p, levels = seq(-180, 180, by = 5), add = FALSE, lon = TRUE) lonlat(p, levels = seq(-180, 180, by = 15), add = TRUE, lat = TRUE)