Created
June 25, 2020 10:42
-
-
Save shrddr/87abf921fd2bcae025648dc0f051c056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LIST = """ул. Налибокская, 34; | |
ул. Якубовского, 34; | |
ул. Шаранговича, 34; | |
ул. Пушкина, 38; | |
ул. Притыцкого, 54; | |
ул. Рафиева, 109; | |
ул. Бурдейного, 25; | |
ул. Ульяновская, 32; | |
ул. Каменногорская, 18; | |
ул. Одинцова, 89; | |
ул. Бельского, 60; | |
ул. Володарского, 2; | |
ул. Дзержинского, 81; | |
ул. Слободская, 153—167; | |
ул. Космонавтов, 3/3; | |
пр. Победителей, 19 («Юбилейная») | |
перекресток ул. Шаранговича — ул. Янковского; | |
С. Ковалевской, 61; | |
ул. Ольшевского, 29/1.""" | |
from geopy.geocoders import Nominatim | |
import geojson | |
geolocator = Nominatim(user_agent="geopy/1.11.0") | |
features = [] | |
for address in LIST.splitlines(): | |
address = "Минск, " + address | |
location = geolocator.geocode(address) | |
if location is None: | |
print(address, "Nominatim fail") | |
continue | |
lonlat = (location.longitude, location.latitude) | |
print(address, lonlat) | |
feature = geojson.Feature(geometry=geojson.Point(lonlat), properties={"name": address}) | |
features.append(feature) | |
feature_collection = geojson.FeatureCollection(features) | |
print(feature_collection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment