You are not logged in.

#1 2022-06-18 10:22:59

amirkhanna121
New Member
Registered: 2022-06-18
Posts: 1

Data from OSM (overpy) to geodataframe with polygons

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'])

QpUXub1

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.

Offline

#2 2022-06-19 08:44:04

mmd
Member
Registered: 2010-11-06
Posts: 2,101

Re: Data from OSM (overpy) to geodataframe with polygons

( Same question was posted here: https://community.openstreetmap.org/t/d … ygons/1738 )

Offline

Board footer

Powered by FluxBB