2016-08-22 8 views
1

最近私の都市のシェープファイルを処理するためにgeopandasを使用し始めました。最近、geopandasのcontainsメソッドを使用して問題を発見しました。問題は次のとおりです。geopandas containsメソッドがポリゴンを返さない

同じcrs投影を持つ2つの異なるシェイプファイルがあります:地区とセクション。私は、地区にあるすべてのセクションポリゴンを取得する必要があります。私は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]) 

は、私はそれを取得しようとしている方法に問題があるのか​​、方法自体に問題ありか?

地区:https://ufile.io/0a6f1

セクション:https://ufile.io/e2463

よろしく

ここに私の問題を繰り返すシェープファイルがあります。

答えて

0

交差点は、2つのポリゴンが重なっている場合はtrueを返しますが、含まれている場合は、1つのポリゴンが完全に別のポリゴン内にある場合のみtrueを返すことを意味します。

関連する問題