首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“未定义名称'pygeos‘”

“未定义名称'pygeos‘”
EN

Stack Overflow用户
提问于 2022-02-22 12:40:17
回答 1查看 1K关注 0票数 1

当执行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吗?谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-05-11 11:20:55

代码语言:javascript
运行
复制
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)

不知何故这是为了我。它是关于按特定顺序设置常量和导入包。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71221500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档