Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal graticules in an orthographic projection #605

Closed
rasmerla opened this issue Oct 11, 2021 · 3 comments
Closed

Horizontal graticules in an orthographic projection #605

rasmerla opened this issue Oct 11, 2021 · 3 comments
Labels

Comments

@rasmerla
Copy link

rasmerla commented Oct 11, 2021

I'm working on orthographic projections of earth, but encounter unwanted horizontal lines when the map centre is beyond 45° east or west (depends also on the north/south angle).
image

Reproducible code:

library(sf)
library(tmap)
sf::sf_use_s2(FALSE)

globe_grid_problem <- function(lat, lon) {
  # Define the orthographic projection
  # Choose lat_0 with -90 <= lat_0 <= 90 and lon_0 with -180 <= lon_0 <= 180
  ortho <- paste0('+proj=ortho +lat_0=',
      lat,
      ' +lon_0=',
      lon,
      ' +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs'
      )

  # Tog get something to plot, make a cirkle around the mid point:
  plot_point <- st_point(c(lon, lat)) %>%
    st_sfc(crs=4326) %>% # Project to WGS84
    st_as_sf() %>% 
    st_transform(crs = ortho) %>% # Transform to the custom projection
    st_buffer(6371000) # buffer to cover the world.

  #qtm(plot_point, projection = ortho)
  # Plot
  tm_shape(plot_point, projection = ortho) +
    tm_polygons(col = "grey") +
    tm_graticules() %>%
    return()
}

globe_grid_problem(45,45) # Works fine
globe_grid_problem(45,-160) # Does not work fine

P.S. Graticules do not work at all if s2 is TRUE. Should I report this?

@mtennekes
Copy link
Member

Good question. To be honest, fixing these graticules in tmap3 has low priority.

However, I'd plan to implement orthogonal maps in tmap4, along with the graticules. See also #457 and #564

@mtennekes
Copy link
Member

Re P.S. it worked on my machine with s2 enabled, so probably an update will fix that for you.

@Nowosad
Copy link
Member

Nowosad commented Sep 18, 2023

The discussion can be continued at #457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants