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

Figure.tilemap: handle longitude given as 0°-360° #2591

Open
yvonnefroehlich opened this issue Jul 3, 2023 · 2 comments
Open

Figure.tilemap: handle longitude given as 0°-360° #2591

yvonnefroehlich opened this issue Jul 3, 2023 · 2 comments
Labels
feature request New feature wanted

Comments

@yvonnefroehlich
Copy link
Member

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.

import pygmt as gmt

region_lon360 = [120, 190, -48, -9]

fig = gmt.Figure()

fig.tilemap(
    region=region_lon360,
    projection="M10c",
    zoom=2,
    frame=["WSne+ttilemap", "af"],
)

fig.shift_origin(xshift="11c")

fig.coast(
    region=region_lon360,
    projection="M10c",
    shorelines="1/1p,black",
    water="steelblue",
    frame=["wSne+tcoast", "af"],
)

fig.shift_origin(xshift="11c")

fig.grdimage(
    region=region_lon360,
    projection="M10c",
    grid="@earth_relief_01d_g",
    frame=["wSne+tremote dataset", "af"],
)

fig.show()
# fig.savefig(fname="tilemap_lon0to360.png")

Output figure:
tilemap_lon0to360

@yvonnefroehlich yvonnefroehlich added bug Something isn't working question Further information is requested feature request New feature wanted labels Jul 3, 2023
@weiji14
Copy link
Member

weiji14 commented Jul 3, 2023

Hmm, a few things:

  1. 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
    region : list
    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``.

    region : list
    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``.
  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. 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 seisman removed bug Something isn't working question Further information is requested labels Jul 4, 2023
@seisman
Copy link
Member

seisman commented Jul 4, 2023

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.

Sounds good.

@seisman seisman added this to the 0.11.0 milestone Sep 16, 2023
@seisman seisman changed the title Let Figure.tilemap handle longitude given as 0°-360° Figure.tilemap: handle longitude given as 0°-360° Oct 9, 2023
@seisman seisman modified the milestones: 0.11.0, 0.12.0 Dec 11, 2023
@seisman seisman removed this from the 0.12.0 milestone Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

No branches or pull requests

3 participants