Python geopandas包含方法不';t返回多边形

Python geopandas包含方法不';t返回多边形,python,shapefile,geopandas,Python,Shapefile,Geopandas,我最近开始使用geopandas处理我所在城市的形状文件。最近,我在使用geopandas中的contains方法时发现了一个问题。问题如下: 我得到了两个具有相同crs投影的不同形状文件:区域和剖面。我需要获得一个区域内的所有截面多边形。我读过contains方法,它看起来正是我所需要的,但是在运行它的时候,返回的多边形是空的。奇怪的是,当我使用intersects方法时,它会返回区域内的部分,以及该区域的所有相邻部分 以下是我的代码: districts = GeoDataFrame.fro

我最近开始使用geopandas处理我所在城市的形状文件。最近,我在使用geopandas中的contains方法时发现了一个问题。问题如下:

我得到了两个具有相同crs投影的不同形状文件:区域和剖面。我需要获得一个区域内的所有截面多边形。我读过contains方法,它看起来正是我所需要的,但是在运行它的时候,返回的多边形是空的。奇怪的是,当我使用intersects方法时,它会返回区域内的部分,以及该区域的所有相邻部分

以下是我的代码:

districts = GeoDataFrame.from_file('districts_WGS84.shp')
sections = GeoDataFrame.from_file('sections_WGS84.shp')

districts.crs == sections.crs #To be sure the files share the same crs

#The following line returns an empty array, but it should return all seccions within a district
print len(sections[sections.contains(districts.geometry[34]) == True])
# districts.geometry[34] is a fixed discrict in order to run a test

#The following line returns the list of all sections within the district plus adjacent ones
print len(sections[sections.intersects(districts.geometry[34]) == True])
我是如何得到它的,还是方法本身有问题

下面是重复我的问题的shapefile:

地区:

章节:


关于。

相交意味着如果两个多边形重叠,它将返回true;而包含意味着只有当一个多边形完全位于另一个多边形内时,它才会返回true。

相交意味着如果两个多边形重叠,它将返回true,然而,contains意味着只有当一个多边形完全位于另一个多边形内时,它才会返回true