Path: blob/main/docs/user_guide/geojson/geopandas_and_geo_interface.md
1602 views
Using GeoPandas.GeoDataFrame in folium
GeoPandas is a project to add support for geographic data to pandas objects. (See https://github.com/geopandas/geopandas)
It provides (among other cool things) a GeoDataFrame
object that represents a Feature collection. When you have one, you may be willing to use it on a folium map. Here's the simplest way to do so.
In this example, we'll use the same file as GeoPandas demo ; it's containing the boroughs of New York City.
To create a map with these features, simply put them in a GeoJson
:
Quite easy.
Adding style
Well, you can also take advantage of your GeoDataFrame
structure to set the style of the data. For this, just create a column style
containing each feature's style in a dictionary.
Use any object with __geo_interface__
Folium should work with any object that implements the __geo_interface__
but be aware that sometimes you may need to convert your data to epsg='4326'
before sending it to folium
.