当执行df = gpd.GeoDataFrame(df1,crs = 'EPSG:4326',几何学=geopandas.points_from_xy(df1.经度,df1.纬度))时,我得到了“没有定义名称' pygeos‘”,但是我已经在我开发的目录中安装了pygeos
python3.9/site-packages/geopandas/_vectorized.py in points_from_xy(x,y,z) 247 248如果compat.USE_PYGEOS:-> 249返回pygeos.points(x,y,z) 250个out = _points_from_xy(x,y,z)
anf导入pygeos在脚本中。为了避免这样的错误,有什么方法可以很好地安装pygeos吗?谢谢
发布于 2022-05-11 11:20:55
USE_PYGEOS=1
import pyproj
import shapely
import pandas as pd
pd.options.display.max_rows = 100
import geopandas as gpd
import numpy as np
import sklearn
import matplotlib.pyplot as plt
gpd.show_versions()
print(gpd.options.use_pygeos)
location_df = pd.read_csv("location_01-03_01-04.csv", sep = ";")
import rtree
import pygeos
gpd.options.use_pygeos = True
#Point is (longitude, latitude)
# Function making geopandas points of latitude, longitude
location_geo = gpd.GeoDataFrame(location_df, crs = 'EPSG:4326', geometry = gpd.points_from_xy(location_df.longitude, location_df.latitude))
departments_df = gpd.read_file("departements.geojson", sep = ";")
print(departments_df)
import time
start = time.time()
print("hello")
import geopandas
import rtree
# Function to check wether a department contains a position - returns the department of the position. NaN values are probably in another country
dept_points = geopandas.sjoin(location_geo, departments_df)
end = time.time()
print(end-start, ' s')
print(dept_points)
不知何故这是为了我。它是关于按特定顺序设置常量和导入包。
https://stackoverflow.com/questions/71221500
复制相似问题