You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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?
The text was updated successfully, but these errors were encountered:
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).
Reproducible code:
P.S. Graticules do not work at all if s2 is TRUE. Should I report this?
The text was updated successfully, but these errors were encountered: