Код: Выделить всё
import shapefile
from shapely.geometry import shape, Point
# read your shapefile
r = shapefile.Reader("C:\\filename.shp")
# get the shapes
shapes = r.shapes()
# build a shapely polygon from your shape
hold = []
for k in range(len(shapes)-1):
polygon = shape(shapes[k])
hold.append(polygon)
for x in df.Coords:
if polygon.contains(Point(x)):
hold.append(x)
Код: Выделить всё
from shapely.geometry import Polygon, Point, MultiPolygon
import shapefile
polygon = shapefile.Reader("C:\\filename.shp")
polygon = polygon.shapes()
shpfilePoints = [ shape.points for shape in polygon ]
#print(shpfilePoints)
polygons = shpfilePoints
hold = []
for polygon in polygons:
poly = Polygon(polygon)
hold.append(poly)
for x in hold:
for y in df.Coords:
if x.contains(Point(y)):
hold.append(y)
print('hold',hold)
Код: Выделить всё
df.CoordsПодробнее здесь: https://stackoverflow.com/questions/529 ... ltipolygon
Мобильная версия