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
{{ message }}
Repository navigation
Figure.tilemap: handle longitude given as 0°-360° #2591
pygmt.Figure.coast and the remote datasets (plotted via pygmt.Figure.grdimage) support that the longitude is given either as -180° to 180° East or as 0° to 360° East. However, it looks like the later longitude range is not supported by pygmt.Figure.tilemap. When plotting tiles for a region exceeding 180° East, the area after 180° East remains empty.
We should probably document that the lonlat range is from -180 to +180, or have a way of converting 0-360 coordinates to -180 to +180 before calling contextily.bounds2img. Specifically these lines
The bounding box of the map in the form of a list [*xmin*, *xmax*,
*ymin*, *ymax*]. These coordinates should be in longitude/latitude if
``lonlat=True`` or Spherical Mercator (EPSG:3857) if ``lonlat=False``.
Ideally, the cross dateline support can be added upstream into contextily (or xyzservices?), and we should at least try to open up an issue to see if they're interested in handling it. I actually need to check if EPSG:3857 and EPSG:4326 tile servers actually support returning cross-dateline tiles. If not, then we may need to add the logic of fetching tiles to the West and East of the international dateline separately and stitch them back together.
2. Ideally, the cross dateline support can be added upstream into contextily (or xyzservices?), and we should at least try to open up an issue to see if they're interested in handling it.
2. Ideally, the cross dateline support can be added upstream into contextily (or xyzservices?), and we should at least try to open up an issue to see if they're interested in handling it. I actually need to check if EPSG:3857 and EPSG:4326 tile servers actually support returning cross-dateline tiles.
contextily/xyzservices assumes that all tiles come in web mercator (EPSG:3857) (source: geopandas/xyzservices#99 (comment)) and web mercator's center location is (0, 0) and has a bound range (-20037508.34, 20037508.34, -20048966.1, 20048966.1) which corresponds to (-180.0, 180.0, -85.06, 85.06) in WGS84 CRS (source: https://epsg.io/3857). So, I think it's unlikely that xyzservices can return cross-dateline tiles.
If not, then we may need to add the logic of fetching tiles to the West and East of the international dateline separately and stitch them back together.
Yes, we can do it. For example, for a longitude range with west=150, east=200, we can split into two parts, west=150, east=180, and west=-180, east=-160, and call contextily.bounds2img twice, like:
However, the problem is, currently load_tile_map always returns images in EPSG:3857 CRS. We can merge image1 and image2 into a single data array, but we can't merge extent1 and extent2, because extent1 is [16697923.62, 20037508.34, ..., ...] and extent2 is [-20037508.34, -17811118.52, ..., ...].
Since the cross-dateline issue only exists when lonlat=True, I think the solution is,
Activity
weiji14 commentedon Jul 3, 2023
Hmm, a few things:
contextily.bounds2img. Specifically these linespygmt/pygmt/datasets/tile_map.py
Lines 27 to 30 in 91e29f1
pygmt/pygmt/src/tilemap.py
Lines 57 to 60 in 91e29f1
contextily(or xyzservices?), and we should at least try to open up an issue to see if they're interested in handling it. I actually need to check if EPSG:3857 and EPSG:4326 tile servers actually support returning cross-dateline tiles. If not, then we may need to add the logic of fetching tiles to the West and East of the international dateline separately and stitch them back together.seisman commentedon Jul 4, 2023
Sounds good.
[-]Let Figure.tilemap handle longitude given as 0°-360°[/-][+]Figure.tilemap: handle longitude given as 0°-360°[/+]seisman commentedon Oct 25, 2024
contextily/xyzservices assumes that all tiles come in web mercator (EPSG:3857) (source: geopandas/xyzservices#99 (comment)) and web mercator's center location is (0, 0) and has a bound range (-20037508.34, 20037508.34, -20048966.1, 20048966.1) which corresponds to (-180.0, 180.0, -85.06, 85.06) in WGS84 CRS (source: https://epsg.io/3857). So, I think it's unlikely that xyzservices can return cross-dateline tiles.
Yes, we can do it. For example, for a longitude range with west=150, east=200, we can split into two parts,
west=150, east=180, andwest=-180, east=-160, and callcontextily.bounds2imgtwice, like:However, the problem is, currently
load_tile_mapalways returns images in EPSG:3857 CRS. We can mergeimage1andimage2into a single data array, but we can't mergeextent1andextent2, becauseextent1is[16697923.62, 20037508.34, ..., ...]andextent2is[-20037508.34, -17811118.52, ..., ...].Since the cross-dateline issue only exists when
lonlat=True, I think the solution is,crs) toload_tile_mapto allow changing CRS of the returned image (load_map_tiles: Allow a new parameter to control the projection of the returned DataArray #3484)lonlat=Trueandcrsis set to something likeOGC:CRS84.