Adding a WMS layer using Python (folium)

577 views
Skip to first unread message

ezgi koker

unread,
Jul 15, 2022, 5:32:11 AM7/15/22
to GeoAdminCh API
Hello,

I am using folium package in Python to construct the map in this link:

For basic map creation I am using: 

map_geo = folium.Map(location=[47.46901, 9.36688], zoom_start=13)

And then try to add the layer as wms layer:

folium.raster_layers.WmsTileLayer(url = 'https://wms.geo.admin.ch/?',
                                  layers = 'ch.bfe.fernwaerme-nachfrage_wohn_dienstleistungsgebaeude',
                                  transparent = False, 
                                  control = True, 
                                  name = 'energy',
                                  overlay=True,
                                  show = True,
                                  ).add_to(map_geo)
folium.LayerControl().add_to(map_geo)

In the end the final map looks like the jpeg in the attachments. If I choose the base layer alone from the layer control then I can see it. But if I activate the energy usage layer, background layer is going all white. What am I doing wrong?

Best regards,

Ezgi



map.jpg

Pasquale Di Donato

unread,
Jul 23, 2022, 12:44:51 PM7/23/22
to GeoAdminCh API
what if you set transparent=True?

ezgi koker

unread,
Jul 25, 2022, 10:17:50 AM7/25/22
to GeoAdminCh API
I tried but it didn't solve the problem. At the end I managed to solve it by adding 'fmt="image/png" ' to the parameters. 

Pasquale Di Donato

unread,
Jul 26, 2022, 8:01:08 AM7/26/22
to GeoAdminCh API
Since you were using the jpeg format, I guess
Reply all
Reply to author
Forward
0 new messages