I try to put OSM data (some polygons) to geodataframe. Export from OSM contains LineString. But in the end i need to conerte all data into geodataframe in this format:
0 → name_from_tag_first_area → polygon (or multipolygon) type with coordinates
1 → name_from_tag_second_area → polygon (or multipolygon) type with coordinates
And then i will use this GeoDataFrame to visualize this polygons.
import overpy
import requests
import json
import geopandas as gpd
from shapely.geometry import shape
url = "https://maps.mail.ru/osm/tools/overpass/api/interpreter"
query = """[out:json];
area['boundary' = 'administrative']['name' = 'Москва'] -> .MSK;
(
relation(area.MSK)['admin_level' = 8]['boundary' = 'administrative']['name'='Бескудниковский район'];
relation(area.MSK)['admin_level' = 8]['boundary' = 'administrative']['name'='район Восточное Дегунино'];
);
convert item ::=::,::geom=geom(),_osm_type=type();
out geom;"""
response = requests.get(url, params={'data': query})
data = response.json()
geo_df = gpd.GeoDataFrame(data['elements'])
In my dataframe not a polygons - only geometrycollection with LineString. Please could you explain how I can do this taskю Thanks.
In my dataframe not a polygons - only geometrycollection with LineString. Please could you explain how I can do this taskю Thanks.