Skip to content

plot fails to render with specific lon_0 value in coord_sf crs string (works with lon_0=27.1, fails with lon_0=27.0) #6180

Closed as not planned
@misea

Description

@misea

I found a problem with rendering a world map with a very specific rotation (I was just trying to animate a rotating globe)
I expected any valid integer value of lon0 in my crs string of this form to work:

coord_sf(crs = "+proj=ortho +lat_0=0 +lon_0=27") 

but it fails with that specific string, while succeeding with other similar values

library(ggplot2)
library(rnaturalearth)
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE

world <- ne_countries(scale = "medium", returnclass = "sf")


world_plot <- ggplot(data = world) +
   geom_sf(fill = "lightblue", color = "gray") +
     theme_void()

# This works
world_plot + coord_sf(crs = "+proj=ortho +lat_0=0 +lon_0=26.9") 

# So does this
world_plot + coord_sf(crs = "+proj=ortho +lat_0=0 +lon_0=27.1") 

  
# But this fails with "Error in `grid.Call.graphics"
world_plot + coord_sf(crs = "+proj=ortho +lat_0=0 +lon_0=27.0") 
#> Error in grid.Call.graphics(C_path, x$x, x$y, index, switch(x$rule, winding = 1L, : Invalid graphics path

Created on 2024-11-10 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions