'GeoDataFrame' object has no attribute 'explore'

Viewed 3406

I wanted to try Geopanda's interactive visualization, and the function .explore() unfortunatly I have this error message : 'GeoDataFrame' object has no attribute 'explore' Which is quite weird as GeoDataFrame should be compatible with explore (https://geopandas.org/docs/reference/api/geopandas.GeoDataFrame.explore.html). I'm using Geopandas v. 0.9.0. and my code is :

import folium
import pandas as pd
import geopandas as gpd

from sqlalchemy import create_engine
engine = create_engine('postgresql://docker:docker@127.0.0.1:25432/mobilitydb')
query=gpd.read_postgis("Select traja,mmsia from filtered where nm_a is not null and geometrytype(traja)='LINESTRING'",engine,geom_col='traja')
plot=query.explore()

does anyone as an idea ?

3 Answers

I think the issue is with the version of Geopandas you are using. I had a similar issue. I had originally installed geopandas from the apt repository(I am using Kali Linux). I uninstalled geopandas, and then installed it using pip3 install geopandas folium matplotlib mapclassify. That seemed to work for me. The version pip installed was geopandas-0.10.1

Try to update your geopandas package (either using conda or pip ) you can use this command :

pip install geopandas==0.10.2

Try to output all attributes of your objects. Use: print(dir(query)) and print(dir(gpd)) There is explore() inside?

Related