python-3.x - 由于 'rtree' 错误,无法连接两个 pandas 数据帧

标签 python-3.x data-visualization geospatial geopandas r-tree

有两个形状文件。我已经使用 geopandas 文件提取了这两个数据。并且成功了。

File 1 : 
zipfile_mobile = "zip://File Saved Location/2020-01-01_performance_mobile_tiles.zip"
mobile_tiles = gp.read_file(zipfile_mobile)

File : 2
zipfile = "zip://File Saved Location/tl_2019_us_county.zip"
counties = gp.read_file(zipfile)

enter image description here enter image description here

现在我想寻找这些数据的交集。在运行以下命令时,我收到如下错误消息。

ky_counties = counties.loc[counties['STATEFP'] == '21'].to_crs(4326)

但是当我这样做的时候出现了下面的错误。

Spatial indexes require either `rtree` or `pygeos`. See installation instructions at https://geopandas.org/install.html

但是已经安装了rtree。

enter image description here

python :3.9.1

另请注意,以下库已导入。

import geopandas as gp
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

from shapely.geometry import Point
from adjustText import adjust_text
import rtree

最佳答案

在我从下面的代码中删除“.to_crs(4326)”后,代码执行成功。

ky_counties = counties.loc[counties['STATEFP'] == '21'].to_crs(4326)

同一个 CRS 通常可以有多种引用方式。例如,最常用的 CRS 之一是 WGS84 经纬度投影。这可以使用权限代码“EPSG:4326”来引用。 这意味着在这种情况下不需要进行此转换。

关于python-3.x - 由于 'rtree' 错误,无法连接两个 pandas 数据帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65283076/

相关文章:

c - 从中心动画正弦波

c# - 通过 EF Core 和 NetTopologySuite 使用半径按区域搜索

r - 更新了 R "maps"包的世界地图?

google-maps - Nodejs 上的 geocouch 错误

python - 使用 .pth 以编程方式附加到 VirtualEnv 中的 PYTHONPATH

python - 使用子图绘制水平线 Matplotlib

python - Windows 控制台上 Python 中的 UnicodeEncodeError

python - 在seaborn barplot之前隐藏文本

python - python3中将十六进制转换为base64的基本方法

python - 有没有办法缩短多个条件,如下所示?