@@ -268,7 +268,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
268268 is_free = function () FALSE ,
269269
270270 # for regular geoms (such as geom_path, geom_polygon, etc.), CoordSf is non-linear
271- is_linear = function () FALSE ,
271+ # if the default_crs option is being used, i.e., not set to NULL
272+ is_linear = function (self ) is.null(self $ get_default_crs()),
272273
273274 distance = function (self , x , y , panel_params ) {
274275 d <- self $ backtransform_range(panel_params )
@@ -588,29 +589,26 @@ calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
588589# ' be projected before plotting. If not specified, will use the CRS defined
589590# ' in the first sf layer of the plot.
590591# ' @param default_crs The default CRS to be used for non-sf layers (which
591- # ' don't carry any CRS information) and scale limits. If not specified, this
592- # ' defaults to the World Geodetic System 1984 (WGS84), which means x and y
593- # ' positions are interpreted as longitude and latitude, respectively. If
594- # ' set to `NULL`, uses the setting for `crs`, which means that then all
592+ # ' don't carry any CRS information) and scale limits. The default value of
593+ # ' `NULL` means that the setting for `crs` is used. This implies that all
595594# ' non-sf layers and scale limits are assumed to be specified in projected
596- # ' coordinates.
595+ # ' coordinates. A useful alternative setting is `default_crs = sf::st_crs(4326)`,
596+ # ' which means x and y positions are interpreted as longitude and latitude,
597+ # ' respectively, in the World Geodetic System 1984 (WGS84).
597598# ' @param xlim,ylim Limits for the x and y axes. These limits are specified
598- # ' in the units of the default CRS. To specify limits in projected coordinates,
599- # ' set `default_crs = NULL`. How limit specifications translate into the exact
599+ # ' in the units of the default CRS. By default, this means projected coordinates
600+ # ' ( `default_crs = NULL`) . How limit specifications translate into the exact
600601# ' region shown on the plot can be confusing when non-linear or rotated coordinate
601- # ' systems are used. First, different methods can be preferable under different
602- # ' conditions. See parameter `lims_method` for details. Second, specifying limits
603- # ' along only one direction can affect the automatically generated limits along the
604- # ' other direction. Therefore, it is best to always specify limits for both x and y.
605- # ' Third, specifying limits via position scales or `xlim()`/`ylim()` is strongly
606- # ' discouraged, as it can result in data points being dropped from the plot even
607- # ' though they would be visible in the final plot region. Finally, specifying limits
608- # ' that cross the international date boundary is not possible with WGS84 as the default
609- # ' crs. All these issues can be avoided by working in projected coordinates,
610- # ' via `default_crs = NULL`, but at the cost of having to provide less intuitive
611- # ' numeric values for the limit parameters.
602+ # ' systems are used as the default crs. First, different methods can be preferable
603+ # ' under different conditions. See parameter `lims_method` for details. Second,
604+ # ' specifying limits along only one direction can affect the automatically generated
605+ # ' limits along the other direction. Therefore, it is best to always specify limits
606+ # ' for both x and y. Third, specifying limits via position scales or `xlim()`/`ylim()`
607+ # ' is strongly discouraged, as it can result in data points being dropped from the plot even
608+ # ' though they would be visible in the final plot region.
612609# ' @param lims_method Method specifying how scale limits are converted into
613- # ' limits on the plot region. For a very non-linear CRS (e.g., a perspective centered
610+ # ' limits on the plot region. Has no effect when `default_crs = NULL`.
611+ # ' For a very non-linear CRS (e.g., a perspective centered
614612# ' around the North pole), the available methods yield widely differing results, and
615613# ' you may want to try various options. Methods currently implemented include `"cross"`
616614# ' (the default), `"box"`, `"orthogonal"`, and `"geometry_bbox"`. For method `"cross"`,
@@ -655,7 +653,7 @@ calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
655653# ' @export
656654# ' @rdname ggsf
657655coord_sf <- function (xlim = NULL , ylim = NULL , expand = TRUE ,
658- crs = NULL , default_crs = sf :: st_crs( 4326 ) ,
656+ crs = NULL , default_crs = NULL ,
659657 datum = sf :: st_crs(4326 ),
660658 label_graticule = waiver(),
661659 label_axes = waiver(), lims_method = c(" cross" , " box" , " orthogonal" , " geometry_bbox" ),
0 commit comments