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

Crossing the international date line #14

Open
yvanrichard opened this issue Nov 21, 2019 · 4 comments
Open

Crossing the international date line #14

yvanrichard opened this issue Nov 21, 2019 · 4 comments

Comments

@yvanrichard
Copy link

Hi. I can't manage to center a map with tiles when data are crossing the international date line.

In the example below, the points are split and placed on opposite sides of the world. When the layer_spatial line is above annotation_map_tile, the centering of the map around the data points is right, but the tiles above 180 degrees of longitude are missing (and it also takes much longer).

Is there a way to do it right?

library(sf)
library(ggspatial)
library(ggplot2)


## Create some data
pts <- st_as_sf(data.frame(lat = seq(-52, -32, length.out = 50),
                           lon = seq(165, 200, length.out = 50)),
                coords = c('lon', 'lat'), crs = 4326)
## Map
g <- ggplot() +
    annotation_map_tile(type = "https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/${z}/${y}/${x}.jpg", zoomin = 0) +
    layer_spatial(data = pts)
g

Cheers

@paleolimbot
Copy link
Owner

The answer is...not yet! There's a chance that the "ggmap" package has this figured out...it's a hard problem!

@yvanrichard
Copy link
Author

Thanks. That's unfortunate. I would have thought with the caching and indexing of individual tiles it would be easier for ggspatial to shift the western tiles to the right of the eastern ones. I haven't had much luck with ggmap either, but maybe I should persevere.

@paleolimbot paleolimbot transferred this issue from paleolimbot/ggspatial Dec 28, 2019
@paleolimbot
Copy link
Owner

Transferring to rosm because this package has the implementation for tile wrapping. Currently tiles are resolved using a min/max approach, but should really be resolved using something more like a intersection approach so that osm.raster() can properly detect situations in which tiles should be wrapped (osm.plot() does this already, so it shouldn't be too bad!)

@mdsumner
Copy link

mdsumner commented Jan 8, 2023

a GDAL api will help solve this, but there's some issues with auto-overview detection just fyi

OSGeo/gdal#7019 (comment)

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

No branches or pull requests

3 participants