Search code examples
pythonpandasgeopandas

Plotting a Geodataframe using naturalearth_lowres


I have a Geodataframe containing geometry points related to fire incidents. I have plotted them on the world's map, using naturalearth_lowres dataset:

world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
gdf.plot(ax=world.plot (figsize=(25,10)), marker='.', color='black')

I would like to do the same with an interactive map this time, but when I replace "plot" with "explore" it gives me an error:

world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
gdf.explore(ax=world.plot (figsize=(25,10)), marker='.', color='black')

TypeError: type object got multiple values for keyword argument 'marker'

Is there any way to do this?


Solution

  • You are mixing matplotlib and folium. They are separate libraries to be used independently.

    • plot() uses matplotlib
    • explore() uses folium

    Have used earthquakes instead of fires for purpose of code. Below will plot lowres earth and earthquake plots on single folium map.

    import geopandas as gpd
    
    world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
    gdf = gpd.read_file("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_week.geojson")
    m = world.explore()
    gdf.explore(m=m, color="black")