Reputation: 523
A lot of goofy things seem to happen when you have to map things in the middle of the Pacific Ocean and your objects span the antimeridian at 180° longitude. In my case, I'm plotting a shapefile (which can be found here) using sf
and ggplot
and there's a solid vertical line at 180°.
Is there a way to get rid of this thing or is it somehow baked into the shapefile? Currently I'm just loading the shapefile, hitting it with an st_shift_longitude
, and plotting it. I tried various iterations of st_combine
and st_union
hoping either one would smash together what appear to be two separate polygons, but to no avail. Here's the basic plot. How can I get rid of this vertical line?
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(tidyverse)
pmnm <- st_read("data/gis/hi_noaa_nwhi_papahanaumokuakea.shp",quiet = TRUE)
ggplot(pmnm %>% st_shift_longitude()) +
geom_sf()
Upvotes: 0
Views: 147
Reputation: 523
It turns out this was a feature of the specific shapefile and how it was being plotted.
Upvotes: 0