Я использую решение Клинта Харриса от этого
import fiona
import shapely
with fiona.open("./areas_shp.shp") as fiona_collection:
shapefile_record = next(iter(fiona_collection))
shape = shapely.geometry.asShape( shapefile_record['geometry'] )
point = shapely.geometry.Point(coords[0])
for point in coords:
if (shape.contains(point)):
print("yay")
Здесь я просто тестирую одну координату с шейп-файлом, но кажется, что код может быть устаревшим. Я уже изменил shapefile_record = fiona_collection.next()
на shapefile_record = next(iter(fiona_collection))
, но эту ошибку не могу решить:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-18ca8979d01f> in <module>
38 with fiona.open("./areas_shp.shp") as fiona_collection:
39 shapefile_record = next(iter(fiona_collection))
---> 40 shape = shapely.geometry.asShape( shapefile_record['geometry'] )
41 point = shapely.geometry.Point(coords[0])
42 for point in coords:
AttributeError: module 'shapely' has no attribute 'geometry'