簡體   English   中英

Python Geopandas 模塊 Object 不可調用

[英]Python Geopandas Module Object Not Callable

我正在嘗試使用 geopandas 在 map 上的 plot x,y 或緯度和經度點,我收到此錯誤:

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

我的代碼如下所示:

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()

我得到的錯誤在第 19 行:

gdf = gdf(dfp, geometry=geometry) 

我認為該錯誤可能與第 19 行的某些內容不是“可調用”且必須是“gdf”有關,但我不確定如何解決此問題。 最終,我需要一個 map,文件中的點在世界 map 上顯示為紅點。 我的 df "dfp" 看起來像這樣 - 謝謝你的幫助!

   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

您正在嘗試導入geopandas.GeoDataFrame class,但正在導入geopandas.geodataframe模塊。 請記住 Python 區分大小寫。

from geopandas import GeoDataFrame as gdf

看起來這是安裝“geopandas”的問題。 我已經刪除然后重新安裝了這個 package 並且沒有發生錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM