pythonmapsgisesriipyleaflet

ipyleaflet layer not scaled/positioned correctly


I'm trying to overlay an esri bathymetry map on my south polar stereographic map using the 'url' function in ipyleaflet. Doing this results with {z}/{y}/{x} in the url inserts the layer, but at a smaller size in the right-hand corner of the basemap. I tried to give the tilelayer the same crs, but that did not change the output. My code is as such:

from ipyleaflet import (
    Map,
    basemaps,
    TileLayer,
    basemap_to_tiles,
    projections) 
from ipywidgets import (Layout, 
    widgets as w 
tile_layer = TileLayer(url='https://tiles.arcgis.com/tiles/C8EMgrsFcRFL6LrL/arcgis/rest/services/Antarctic_Basemap/MapServer/tile/{z}/{y}/{x}')
spsLayout = Layout(width='800px', height='800px')


m = Map(center=(-90, 0),
        zoom=0,
        layout=spsLayout,
        basemap= basemaps.NASAGIBS.BlueMarble3031,
        crs=projections.EPSG3031) 
m.add_layer(tile_layer)

m 

Here's where I got the url for the tiles In the bottom right. Thanks for your help!


Solution

  • I think the issue here is that this bathymetry base map use a different tilegrid(metatiles 3x3) from the one used with ipyleaflet(4x4). Unfortunately I don't think there is currently a way for Leaflet(hence ipyleaflet) to understand multiple tilegrids in the same map. A workaround would be to use ArcGIS in your notebook instead of ipyleaflet but that would require a paid subscription.

    If you don't mind defining your own projection and resolutions you can use the ArcGIS layers and avoid completely thedefault polar projection and basemaps from ipyleaflet. i.e.

    from ipyleaflet import (
        Map,
        basemaps,
        TileLayer,
        basemap_to_tiles,
        projections) 
    
    ESRI_3031 = dict(
        name='EPSG:3031',
        custom=True,
        proj4def="""+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1
            +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs""",
        origin=[-3.06361E7, 3.0636099999999993E7],
        resolutions=[
            67733.46880027094,
            33866.73440013547,
            16933.367200067736,
            8466.683600033868,
            4233.341800016934,
            2116.670900008467,
            1058.3354500042335,
            529.1677250021168,
            264.5838625010584,
        ],
        bounds=[
            [-4524583.19363305,-4524449.487765655],
            [4524449.4877656475,4524583.193633042]
        ]
    )
    
    tile_layer = TileLayer(url='https://tiles.arcgis.com/tiles/C8EMgrsFcRFL6LrL/arcgis/rest/services/Antarctic_Basemap/MapServer/tile/{z}/{y}/{x}')
    spsLayout = Layout(width='800px', height='800px')
    
    
    m = Map(center=(-90, 0),
            zoom=0,
            layout=spsLayout,
            basemap= tile_layer,
            crs=ESRI_3031) 
    m