首页 > 解决方案 > Geopandas 空间连接不返回任何行

问题描述

我正在尝试对我的地理数据框进行空间连接,其中每一行都是访问者

我的 GeoJSON 在这里

import geopandas as gpd
geo_json = gpd.read_file('http://geoportal1-ons.opendata.arcgis.com/datasets/01fd6b2d7600446d8af768005992f76a_0.geojson?outSR={%22latestWkid%22:27700,%22wkid%22:27700}')

几何看起来像这样 - 它不是坐标

多面体(((398583.804 653093.703, 398601....

crs看起来像这样

<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

我的访问者数据中的坐标如下所示 POINT (-2.64185 53.55189)

如果我运行空间连接,并保持与地理 json 相同的 crs,我将没有行

customers = pd.DataFrame({'visitor':[1],'geometry':[Point(0.26371,51.15565)]})
customers_geo = gpd.GeoDataFrame(customers,
crs = geo_json.crs,
geometry = customers.geometry)

customers_geo.head()

spatial_join = gpd.sjoin(geo_json, customers_geo, op = 'contains')

spatial_join

为什么会这样?如果我使用其他 GeoJSON,我会得到行

标签: pythongeospatialgeojsongeopandas

解决方案


推荐阅读