pythonleafletjupyteripyleaflet

Mapping Antarctic Polar Stereographic data in ipyleaflet


I am trying to plot Antarctic Sea-Ice EPSG:3031 data using ipyleaflet like so:


from ipyleaflet import Map, WMSLayer, basemaps

wms = WMSLayer(
    url='http://geos.polarview.aq/geoserver/wms',
    layers='polarview:iceedgeS15',
    format='image/png',
    transparent=True,
    attribution='Polarview'
)

m = Map(basemap=basemaps.NASAGIBS.BlueMarble3031, center=(-90, 0), zoom=1, crs=projections.EPSG3031)

m.add_layer(wms)

m

The photos in the following links illustrate my issues clearly:

The data and the basemap do not align

If I omit the basemap and projection information it looks reasonable in terms of alignment but doesn't have the perspective and projection I desire. I have been also been using Leafmap to add local geotiffs and run into similar issues.

I have read through a few relevant PRs and checked out xarray-leaflet but haven't had any luck. This sea-ice concentration data is an example of a non-wms data source that I encounter the same problem with which could be helpful for testing purposes.


Solution

  • Great question. You'll need to add coordinate reference system (CRS) information to your WMSLayer. See the custom projections notebook within the ipyleaflet examples. For spatial projections that are not Web Mercator (EPSG:3857), you'll likely need to define the bounds of your imagery.

        from ipyleaflet import Map, WMSLayer, basemaps
    
        # create map with NASA Blue Marble as background
        m2 = Map(basemap=basemaps.NASAGIBS.BlueMarble3031,
             center=(-90, 0), zoom=1, crs=projections.EPSG3031)
    
        # projection for Polarview sea ice edge
        POLAR3031 = 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""",
            bounds=[[-2822131.5,-3057369.25],[3744213.75,3822194.25]]
        )
        wms = WMSLayer(
            url='http://geos.polarview.aq/geoserver/wms',
            layers='polarview:iceedgeS15',
            format='image/png',
            transparent=True,
            attribution='Polarview',
            crs=POLAR3031
        )
        m2.add(wms)
    
        # show map
        m2