3

Looking through the Folium documentation I can't find how to add a popup to a polygon GeoJSON layer in Folium. Looking through the Leaflet documentation it seems like its possible, but I don't know how to translate the JavaScript to Python. Below is a snippet of the code I'm using to render the map.

stand_boundary = folium.GeoJson(stands_gdf, name='Stands')

The stands_gdf variable is a GeoJSON read into a GeoDataFrame.

1

1 Answer 1

0

List all columns except 'geometry' culumn of your GeoDataframe and create a popup with these fields

fields = [ column for column in stand_boundary.columns if column not in stand_boundary.select_dtypes('geometry')]

m = folium.Map(tiles='stamentoner')

folium.GeoJson(stand_boundary, popup = folium.GeoJsonPopup(fields = fields)).add_to(m)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.