EVOLUTION-MANAGER
Edit File: st_graticule.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Compute graticules and their parameters</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for st_graticule {sf}"><tr><td>st_graticule {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Compute graticules and their parameters</h2> <h3>Description</h3> <p>Compute graticules and their parameters </p> <h3>Usage</h3> <pre> st_graticule( x = c(-180, -90, 180, 90), crs = st_crs(x), datum = st_crs(4326), ..., lon = NULL, lat = NULL, ndiscr = 100, margin = 0.001 ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>object of class <code>sf</code>, <code>sfc</code> or <code>sfg</code> or numeric vector with bounding box given as (minx, miny, maxx, maxy).</p> </td></tr> <tr valign="top"><td><code>crs</code></td> <td> <p>object of class <code>crs</code>, with the display coordinate reference system</p> </td></tr> <tr valign="top"><td><code>datum</code></td> <td> <p>either an object of class <code>crs</code> with the coordinate reference system for the graticules, or <code>NULL</code> in which case a grid in the coordinate system of <code>x</code> is drawn, or <code>NA</code>, in which case an empty <code>sf</code> object is returned.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>ignored</p> </td></tr> <tr valign="top"><td><code>lon</code></td> <td> <p>numeric; degrees east for the meridians</p> </td></tr> <tr valign="top"><td><code>lat</code></td> <td> <p>numeric; degrees north for the parallels</p> </td></tr> <tr valign="top"><td><code>ndiscr</code></td> <td> <p>integer; number of points to discretize a parallel or meridian</p> </td></tr> <tr valign="top"><td><code>margin</code></td> <td> <p>numeric; small number to trim a longlat bounding box that touches or crosses +/-180 long or +/-90 latitude.</p> </td></tr> </table> <h3>Value</h3> <p>an object of class <code>sf</code> with additional attributes describing the type (E: meridian, N: parallel) degree value, label, start and end coordinates and angle; see example. </p> <h3>Use of graticules</h3> <p>In cartographic visualization, the use of graticules is not advised, unless the graphical output will be used for measurement or navigation, or the direction of North is important for the interpretation of the content, or the content is intended to display distortions and artifacts created by projection. Unnecessary use of graticules only adds visual clutter but little relevant information. Use of coastlines, administrative boundaries or place names permits most viewers of the output to orient themselves better than a graticule. </p> <h3>Examples</h3> <pre> library(sf) library(maps) usa = st_as_sf(map('usa', plot = FALSE, fill = TRUE)) laea = st_crs("+proj=laea +lat_0=30 +lon_0=-95") # Lambert equal area usa <- st_transform(usa, laea) bb = st_bbox(usa) bbox = st_linestring(rbind(c( bb[1],bb[2]),c( bb[3],bb[2]), c( bb[3],bb[4]),c( bb[1],bb[4]),c( bb[1],bb[2]))) g = st_graticule(usa) plot(usa, xlim = 1.2 * c(-2450853.4, 2186391.9)) plot(g[1], add = TRUE, col = 'grey') plot(bbox, add = TRUE) points(g$x_start, g$y_start, col = 'red') points(g$x_end, g$y_end, col = 'blue') invisible(lapply(seq_len(nrow(g)), function(i) { if (g$type[i] == "N" && g$x_start[i] - min(g$x_start) < 1000) text(g[i,"x_start"], g[i,"y_start"], labels = parse(text = g[i,"degree_label"]), srt = g$angle_start[i], pos = 2, cex = .7) if (g$type[i] == "E" && g$y_start[i] - min(g$y_start) < 1000) text(g[i,"x_start"], g[i,"y_start"], labels = parse(text = g[i,"degree_label"]), srt = g$angle_start[i] - 90, pos = 1, cex = .7) if (g$type[i] == "N" && g$x_end[i] - max(g$x_end) > -1000) text(g[i,"x_end"], g[i,"y_end"], labels = parse(text = g[i,"degree_label"]), srt = g$angle_end[i], pos = 4, cex = .7) if (g$type[i] == "E" && g$y_end[i] - max(g$y_end) > -1000) text(g[i,"x_end"], g[i,"y_end"], labels = parse(text = g[i,"degree_label"]), srt = g$angle_end[i] - 90, pos = 3, cex = .7) })) plot(usa, graticule = st_crs(4326), axes = TRUE, lon = seq(-60,-130,by=-10)) </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>