Skip to content

ENH: support overlay tiles #89

@jorisvandenbossche

Description

@jorisvandenbossche

The new providers (https://github.com/darribas/contextily/pull/66) contain also a set of sources for "overlay" tiles (like Stamen.TonerLabels or OpenMapSurfer.AdminBounds).

Those are tiles with a transparent background that can be added on top of another layer. We can load them, but the problem is that currently, due to the way we are reading the image and storing it as an array, the transparent background gets converted into a black background (of course defeating the purpose of being able to overlay it).

Example:

df = geopandas.read_file(geopandas.datasets.get_path('nybb')).to_crs(epsg=3857)
ax = df.plot(figsize=(9, 9), alpha=0.5)
ctx.add_basemap(ax, url=ctx.providers.Stamen.TonerLabels)
# or
ctx.add_basemap(ax, url=ctx.providers.OpenMapSurfer.AdminBounds)

gives

image

If we want to support this, we have to investigate if imshow can support transparency (I think yes, by using alpha / RGBA colors, see eg https://matplotlib.org/3.1.1/gallery/images_contours_and_fields/image_transparency_blend.html) and how to read the tiles into an array with those alpha values included.

All providers that are of overlay type can be seen from this query in the leaflet-providers code:

https://github.com/leaflet-extras/leaflet-providers/blob/9eb968f8442ea492626c9c8f0dac8ede484e6905/preview/preview.js#L56-L70

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions