lets-plot
lets-plot copied to clipboard
Segment don't want to cross the 180th meridian
Example:
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
countries = world[world["name"].isin(["United States of America", "Russia"])]
ggplot() + \
geom_map(map=countries) + \
geom_segment(x=158.634805, y=53.038483, xend=-149.863129, yend=61.217381)
Output:
But, how to draw a segment that connects points along the shorter arc of great circle of Earth's surface? I would prefer it to be the default behavior. When drawing on the Earth's surface, one may follow the same principles as in D3.js.
In ggplot2 there are several ways to deal with such a problem. For example, you can use the function coord_sf()
to change the CRS, or divide the line with st_wrap_dateline()
and shift plot with st_shift_longitude()
, etc.