我正在尝试在 shapefile 的多边形内找到一个点。
我需要编写一个循环来遍历多边形并返回该点所在的多边形的索引。
我将如何编写一个循环来找出该点所在的多边形?
这是我到目前为止所写的:
import pandas as pd
import pylab as pl
import os
import zipfile
import geopandas as gp
import shapely
%pylab inline
# Read in the shapefile
ct_shape = gp.read_file(path)
# Segmented the file so it only contains Brooklyn data & set projection
ct_latlon = ct_shape[ct_shape.BoroName == 'Brooklyn']
ct_latlon = ct_latlon.to_crs({'init': 'epsg:4326'})
ct_latlon.head()
# Dataframe image
[Head of the dataframe image][1]: https://i.stack.imgur.com/xAl6m.png
# Created a point that I need to look for within the shapefile
CUSP = shapely.geometry.Point(40.693217, -73.986403)
输出可能是这样的:'3001100'(正确多边形的 BCTCB2010)