coord_sf() is the coordinate system for mark_sf() maps. Before scale
training it reprojects every sf layer to a common CRS (via
sf::st_transform()), so the renderer only ever sees projected Cartesian
coordinates, and it locks the panel aspect ratio so the map is not stretched:
1 for a projected CRS, and the equirectangular correction
1/cos(mean_latitude) for unprojected longitude/latitude data.
Usage
coord_sf(
plot,
crs = NULL,
xlim = NULL,
ylim = NULL,
graticule = FALSE,
graticule_labels = TRUE
)Arguments
- plot
A PlotSpec.
- crs
Target coordinate reference system to project all layers into (anything
sf::st_crs()accepts, e.g. an EPSG code,"OGC:CRS84", or a proj/WKT string).NULL(default) uses the CRS of the firstsflayer. For guaranteed longitude/latitude order, use"OGC:CRS84"rather thanEPSG:4326. For choropleths, prefer an equal-area CRS.- xlim, ylim
Length-2 view-window limits in the target CRS, or
NULL.- graticule
Draw meridians and parallels behind the map.
FALSE(default) draws none;TRUEpicks round longitude/latitude breaks automatically; a listlist(lon = , lat = )sets the breaks explicitly (in degrees). For a projected CRS the lines are reprojected and therefore curved; for unprojected longitude/latitude they are straight.- graticule_labels
Label the graticule lines with their degree values (default
TRUE); ignored whengraticuleisFALSE.
Value
The modified PlotSpec.
Details
sf is an optional dependency (in Suggests); coord_sf() errors with an
install hint if it is not available at render time.
