Visitar URL original
WmsTileLayer does not recognise transparent parameter · Issue #1808 · python-visualization/folium · GitHub
Skip to content

WmsTileLayer does not recognise transparent parameter #1808

Description

@EmanuelCastanho

Describe the bug
WmsTileLayer is not recognising transparent=True parameter when using NASA WMS service.

To Reproduce

m = folium.Map(tiles="cartodbpositron")
wms_url = "https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi" 
wms = folium.raster_layers.WmsTileLayer(url=wms_url, layers="MODIS_Aqua_CorrectedReflectance_TrueColor", transparent=True,
fmt="image/png", name="Corrected Reflectance", 
styles="default", time="2023-09-22", overlay=True, show=True)
wms.add_to(m)
m

Expected behavior
I expect the black parts to be transparent

Environment (please complete the following information):

  • Jupyter Notebook
  • Python 3.9
  • folium latest version

Possible solutions
I already tried to include that parameter on kwargs, change True to "True", "true" and "True", but does not work.

Activity

  1. Htet-Kaung-San commented on Jul 25, 2026

    @Htet-Kaung-San
    Contributor

    I don't think this one is folium's doing — transparent=True does reach Leaflet correctly.

    Rendering the example from the report and inspecting the emitted options:

    import folium
    
    m = folium.Map(tiles="cartodbpositron")
    folium.raster_layers.WmsTileLayer(
        url="https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi",
        layers="MODIS_Aqua_CorrectedReflectance_TrueColor",
        transparent=True, fmt="image/png", styles="default",
    ).add_to(m)
    print(m.get_root().render())

    gives:

    L.tileLayer.wms("https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi", {"attribution": "", "format": "image/png", "layers": "MODIS_Aqua_CorrectedReflectance_TrueColor", "styles": "default", "transparent": true, "version": "1.1.1"})

    So "transparent": true is in the WMS request options as expected — WmsTileLayer.__init__ passes it straight through parse_options.

    The black areas are almost certainly the imagery itself rather than a transparency setting. WMS transparent=true controls the background where the server renders nothing; it doesn't make rendered black pixels transparent. MODIS_Aqua_CorrectedReflectance_TrueColor is a daily composite, so the night side of the orbit and any gaps come back as actual black pixels in the returned PNG.

    @EmanuelCastanho if you still have this handy, it'd be worth checking whether GIBS returns the same black areas when you request that tile URL directly in a browser, outside folium. If so this can probably be closed as not-our-bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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