I'd like to extract, given a city name, all suburbs and relative polygon geometries. For instance: https://nominatim.articque.com/details.php?place_id=230259366 enter image description here So, I run the code:

place = 'Torino, Italia'
tags = {'place':'suburb'}
gdf = ox.geometries_from_place(place, tags)

When reading gdf content, some suburbs have been stored as polygons (what I wanted), but some others have been stored as points. The one in the previous picture, for instance, belongs to the latter group.

enter image description here

unique_id                    node/6173683209
osmid                             6173683209
element_type                            node
geometry        POINT (7.6801517 45.0549503)
name                            San Salvario
place                                 suburb
reg_name                                 NaN
wikidata                                 NaN
wikipedia                                NaN
name:pms                                 NaN
nodes                                    NaN
ways                                     NaN
description                              NaN
type                                     NaN
Name: 14, dtype: object

While others, as already mentioned, are polygons, just like this one.

enter image description here

unique_id                                        relation/9169020
osmid                                                     9169020
element_type                                             relation
geometry        POLYGON ((7.6628873 45.068484, 7.663573 45.069...
name                                                       Centro
place                                                      suburb
reg_name                                                      NaN
wikidata                                                      NaN
wikipedia                                                     NaN
name:pms                                                      NaN
nodes           [[[13929743, 1669480276, 538902963], [53890296...
ways            [160600494, 572748521, 134148111, 111863124, 1...
description     Confini dell'ex Quartiere 1 della divisione a 23.
type                                                 multipolygon
Name: 41, dtype: object

How can I get all suburbs as Polygons?

  • Please provide links instead of screenshots of web pages, and text output rather than dataframe screenshots. It makes it much easier to troubleshoot your results without having to try to type long OSM IDs from your images. – gboeing Feb 5 at 17:37
  • My mistake. Thank you for the advise. – GiuseppeBrenk Feb 5 at 19:54

From what I understand, this node is what you are currently getting, but this relation is what you actually want. On OSM, the San Salvario place:suburb is represented as a node but its boundary is represented as a relation comprising its center (the node linked above) plus the set of ways making up its outer polygon.

Currently, the OSMnx geometries module only handles OSM relations of type multipolygon. As we're not currently handling boundary relations, we get some inconsistent effects. For example, in Turin this suburb's boundary is represented as a multipolygon relation but this suburb's boundary is represented as a boundary relation.

I've opened a proposal at the OSMnx Github repo to fix this. Comments welcome.

  • Yes, thank you. My doubt is: why are some suburbs (former example) collected as points even if a boundary relation is available, and, at the same time, some others (latter) are stored as boundary relation. And what about MULTIPOLYGON, how can I get the polygons of sub-areas in a city? – GiuseppeBrenk Feb 8 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.