简体   繁体   中英

Python Geopandas Module Object Not Callable

i am trying to plot x,y or latitude and longitude points on a map using geopandas and I am getting this error:

File "C:\Users\U321103\.spyder-py3\Plot90thPercentile_MKTest_maps.py", line 
19, in <module>
gdf = gdf(dfp, geometry=geometry)
TypeError: 'module' object is not callable

My code looks like this:

from sys import exit
from shapely.geometry import Point
import geopandas as gpd
from geopandas import geodataframe as gdf
from shapely.geometry import Point, LineString
import pandas as pd


dfp = pd.read_csv("\\\porfiler03\\gtdshare\\Long_Lats_90p.csv", 
delimiter=',', skiprows=0, 
low_memory=False)
geometry = [Point(xy) for xy in zip(dfp['Longitude'], dfp['Latitude'])]
gdf = gdf(dfp, geometry=geometry)   

#this is a simple map that goes with geopandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
gdf.plot(ax=world.plot(figsize=(10, 6)), marker='o', color='green', 
markersize=15);
exit()

The error i am getting is on line 19:

gdf = gdf(dfp, geometry=geometry) 

The error i think might be related to the fact that something on line 19 is not "callable" and it must be "gdf" but I'm not sure how to fix this. Ultimately, i need a map with the points in my file to show up as red dots on a world map. My df "dfp" looks like this - thank you for your help!

   Longitude  Latitude
0    -76.124    40.853
1    -96.063    44.065
2     -3.480    43.140
3     -2.060    38.750
4     -2.420    38.880

You are trying to import geopandas.GeoDataFrame class, but are importing geopandas.geodataframe module instead. Remember that Python is case sensitive.

from geopandas import GeoDataFrame as gdf

It looks like this was a problem with installing "geopandas". I have removed and then re-installed this package and the error does not occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM