Search code examples
pythongeopandasfolium

How to select a polygon and use it as a clipping mask for other layers in Folium?


I have a geoJSON file of local authorities and several other layers shown on the same Folium map. I want the user to select a polygon (one of the local authorities) and then turn on other layers. I want these layers to be clipped to a polygon that user selected.

Snapshot of the map.

I would assume geopandas would do the clipping, but I can't get my head around on selecting a polygon and how to perform analysis on it. Is this even possible with Folium, or would this need to be done in combination with javascript?

I am not expecting the exact code example, but if someone could point me in the right direction that would be appreciated already.


Solution

  • I think ipyleaflet will help in solving your problem.

    Please check it's GitHub repo and documentation.