Код: Выделить всё
import geopandas as gpd
Slat = 43
Nlat = 44
Wlon = -109
Elon = -108
NW = geometry.Point(Nlat,Wlon)
NE = geometry.Point(Nlat,Elon)
SE = geometry.Point(Slat,Elon)
SW = geometry.Point(Slat,Wlon)
list = [NW, NE, SE, SW, NW]
MyMap = geometry.Polygon(list)
Boundaries = "C:...\\OSM\\Example\\Example"
boundgdf = gpd.read_file(Boundaries+'.shp')
Inside = boundgdf['geometry'].contains(MyMap)
print(len(Inside))
for i in range(len(Inside)):
if Inside[i] == True:
print(boundgdf['Continent'][i], boundgdf['Country'][i], boundgdf['SubRegion'][i])
Выход/Вход
Тип
геометрия
Вход
Континент
ПОЛИГОН ((-171.2 83.3, -49 83.3, -49 6.6, -171.2 6.6, -171.2 83.3))
Вне
Страна
ПОЛИГОН((-141 83.3, -55 83.3, -55 45, -141 45, -141 83.3))
В
Стране
ПОЛИГОН((-131.5 50, -67 50, -67 25, -131.5 25, -131.5 50))
Вне
Континент
ПОЛИГОН (( -122.9 -60.2, -122.9 2, -28.7 2, -28,7 -60,2, -122,9 -60,2))
Код: Выделить всё
Out/In
Type
geometry
In
Continent
POLYGON ((-171.2 83.3, -49 83.3, -49 6.6, -171.2 6.6, -171.2 83.3))
Out
Country
POLYGON((-141 83.3, -55 83.3, -55 45, -141 45, -141 83.3))
In
Country
POLYGON((-131.5 50, -67 50, -67 25, -131.5 25, -131.5 50))
Out
Continent
POLYGON (( -122.9 -60.2, -122.9 2, -28.7 2, -28.7 -60.2, -122.9 -60.2))
Код: Выделить всё
4
In, Continent
In, Country
Подробнее здесь: https://stackoverflow.com/questions/798 ... -shapefile
Мобильная версия