st_break_antimeridian: Break antimeridian for plotting not centred on Greenwich

View source: R/break_antimeridian.R

st_break_antimeridianR Documentation

Break antimeridian for plotting not centred on Greenwich

Description

Longitudes can be broken at the antimeridian of a target central longitude to permit plotting of (usually world) line or polygon objects centred on the chosen central longitude. The method may only be used with non-projected, geographical coordinates and linestring or polygon objects. s2 is turned off internally to permit the use of a rectangular bounding box. If the input geometries go outside ⁠[-180, 180]⁠ degrees longitude, the protruding geometries will also be split using the same tol= values; in this case empty geometries will be dropped first.

Usage

st_break_antimeridian(x, lon_0 = 0, tol = 1e-04, ...)

## S3 method for class 'sf'
st_break_antimeridian(x, lon_0 = 0, tol = 1e-04, ...)

## S3 method for class 'sfc'
st_break_antimeridian(x, lon_0 = 0, tol = 1e-04, ...)

Arguments

x

object of class sf or sfc

lon_0

target central longitude (degrees)

tol

half of break width (degrees, default 0.0001)

...

ignored here

Examples


if (require("maps", quietly=TRUE)) {
 opar = par(mfrow=c(3, 2))
 wld = st_as_sf(map(fill=FALSE, interior=FALSE, plot=FALSE), fill=FALSE)
 for (lon_0 in c(-170, -90, -10, 10, 90, 170)) {
  wld |> st_break_antimeridian(lon_0=lon_0) |>
   st_transform(paste0("+proj=natearth +lon_0=", lon_0)) |>
   st_geometry() |> plot(main=lon_0)
 }
 par(opar)
}


r-spatial/sf documentation built on April 23, 2024, 8:36 a.m.