question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

non standard projections for gv.WMTS tiles

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’d like to be able to utilize WMTS tiles in a projection other Web Mercator (EPSG:3857), which currently does not seem possible. This is especially useful for Polar regions, where Polar Stereographic projections are commonly used. This functionality is available via ipyleaflet (https://github.com/jupyter-widgets/ipyleaflet/blob/master/examples/CustomProjections.ipynb), so I’m assuming the same should be possible with geoviews…

Describe the solution you’d like

I’d like to either be able to point to a pre-tiled non-EPSG:3857 WMTS such as https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers#GIBSAPIforDevelopers-Projections&Resolution , or have MapTiles reprojected on the fly.

import geoviews as gv
import geopandas as gpd
from shapely import geometry
import cartopy.crs as ccrs
import hvplot.pandas

S,N,W,E = [74.5, 80, -102, -98]
bbox = geometry.box(W,S,E,N)
gf = gpd.GeoDataFrame(geometry=[bbox], crs=4326)

crs = ccrs.NorthPolarStereo(central_longitude=-45, true_scale_latitude=70)
print(crs.proj4_init)
print(gf.crs)

# Tiles in EPSG3413 ?
tiles = gv.WMTS('https://gibs.earthdata.nasa.gov/wmts/epsg3413/best/BlueMarble_NextGeneration/default/EPSG3413_500m/{Z}/{Y}/{X}.jpeg',
                crs=crs)

box = gf.hvplot.polygons(line_color='m', fill_color='m', fill_alpha=0.1, 
                         ylim=(70,90), xlim=(-180, 180),
                         coastline=True, projection=crs)
tiles * box

Describe alternatives you’ve considered

Using tiles=True keyword also produces an incorrect map without any tracebacks or warnings, so perhaps this should also be considered a bug and an error or warning is needed. Or maybe reprojecting on the fly is possible and I’m just unable to figure out the right incantation of settings?

Additional context

related issues: https://github.com/holoviz/geoviews/issues/427, https://github.com/holoviz/geoviews/issues/357

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
philippjfrcommented, Mar 13, 2021

One trick now that I’ve merged the gv.get_tile_rgb utility would be to have a dynamicmap which fetches the tiles server-side and then projects them:

stream = hv.streams.RangeXY()
size = hv.streams.PlotSize(width=400, height=400)
def tile_xy(x_range, y_range, width, height, scale):
    x_range = x_range or ccrs.GOOGLE_MERCATOR.x_limits
    y_range = y_range or ccrs.GOOGLE_MERCATOR.y_limits
    x0, x1 = x_range
    y0, y1 = y_range
    bounds = (x0, y0, x1, y1)
    lat_lon = gv.util.project_extents(bounds, ccrs.GOOGLE_MERCATOR, ccrs.PlateCarree())
    zoom = gv.util.zoom_level(lat_lon, width, height)
    return gv.util.get_tile_rgb(gv.tile_sources.ESRI(), bounds, zoom, ccrs.GOOGLE_MERCATOR)
hv.DynamicMap(tile_xy, streams=[stream, size]).opts(projection=ccrs.Orthographic(), width=500, height=500)

tile_source

1reaction
jbednarcommented, Jul 9, 2021

Ok, then that specific bit is not supported; instead if you want to delay reprojection, you’ll currently need the final plotting projection to be Web Mercator. Hopefully we can get to this issue sometime soon and remove that limitation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set extent for WMTS tile - GeoViews - HoloViz Discourse
When setting the extent of WMTS tiles, we should convert degree to pass them as xlim or ylim . Here's the example: import...
Read more >
Projections — GeoViews 1.9.5+g5eb9cd4-dirty documentation
As we can see we overlaid the above plot on a WMTS tile source, letting us interactively zoom in and out of the...
Read more >
WMTS - Tile Sources - | notebook.community
GeoViews provides a number of tile sources by default, provided by CartoDB, Stamen, OpenStreetMap, Esri and Wikipedia. These can be imported from the...
Read more >
Tiling and projections — Mapchete 2022.12.0 documentation
Every tile within a tile pyramid can be described by three numbers: the zoom level, row and column. As these numbers are used...
Read more >
OGC Two Dimensional Tile Matrix Set - OGC Standards
This document frees the concept of a tile matrix set from the WMTS standard ... This is common usage for projections that do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found