由于 'rtree' 错误,无法将两个 geopandas 数据框连接起来。

3

有两个形状文件。我使用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)

在这里输入图片描述 在这里输入图片描述

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

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

你使用的是哪个版本的geopandas?0.8.1吗? - martinfleis
是的,Geopandas 0.8.1。 - viththi
1个回答

1
在下面的代码中,如果我删除“.to_crs(4326)”,那么代码执行就会成功。
ky_counties = counties.loc[counties['STATEFP'] == '21'].to_crs(4326)

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接