【问题标题】:Unable to joint two geopandas data framesm due to 'rtree' error由于“rtree”错误,无法加入两个 geopandas 数据框
【发布时间】:2021-03-24 17:48:15
【问题描述】:

有两个 shapefile。我已经使用 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已经安装好了。

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?
  • 是的,Geopandas 0.8.1

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


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多