4

I am generating a polar projection with the rnaturalearth::ne_countries() dataset. Because I'm only interested in high-latitude regions, I want to crop the shape above a particular latitude. However, when I crop, transform, and plot, the southernmost extent of each country that remains in the dataset does not follow latitudinal curves, because only two points represent the southern bounds of the data. For example, the US west coast and east coasts are connected by a straight line, as highlighted in the image below (red rectangle added manually). Ideally, I want the southern "borders" of countries that were cut in half to follow the thin blue dotted line (added manually).

boundaryProblem

How can I get a latitudinal crop + transform to follow curves? Spatial* or sf* solutions are both welcome.

Reproducible example:

library(sf)
library(tidyverse)

countries = rnaturalearth::ne_countries(returnclass = "sf") %>%
  st_crop(y = st_bbox(c(xmin = -180, ymin = 35, xmax = 180, ymax = 90)))
ggplot() +
  geom_sf(data = countries)

countries2 = st_transform(countries,
             crs("+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs"))

ggplot() +
  geom_sf(data = countries2)
1
  • 1
    Maybe you could densify your polygons before transforming? So that by having vertices close together, the reprojection will transform all those vertices and give you a much smoother result.
    – FSimardGIS
    Oct 7 '20 at 21:02
5

As per FSimardGIS's suggestion, I added a call to densify() in my initial pipeline:

countries = rnaturalearth::ne_countries(returnclass = "sf") %>%
  st_crop(y = st_bbox(c(xmin = -180, ymin = 35, xmax = 180, ymax = 90))) %>%
  smoothr::densify(max_distance = 1) %>%
  st_transform(crs("+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs"))

This generated an acceptable approximation of the curve for my purposes: approxCurve

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.