Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create a geometry from a multipolygon relations #74

Closed
ldalzovo opened this issue Sep 17, 2018 · 3 comments
Closed

Can't create a geometry from a multipolygon relations #74

ldalzovo opened this issue Sep 17, 2018 · 3 comments

Comments

@ldalzovo
Copy link

I noticed that I can correctly access objects of type 'area' extending osmium.SimpleHandler and create the geometry object using create_multipolygon(). In this case is then possible to know if the area comes from 'way' or 'relation' using from_way() and both work using a specific pbf extraction of the city of Rome.
Nevertheless, not all the multipolygon relations are available as area unfortunatelly, and I can access them as relation, but I can't create a geometry, as in the case of https://www.openstreetmap.org/relation/11153 or https://www.openstreetmap.org/relation/8655602: it looks valid and therefore it should be possible to get a geometry. I am also sure that all the nodes and ways are in the pbf, so this cannot be the issue here.
Do you have any idea how I can create a valid geometry in these cases? Thank you!

@lonvia
Copy link
Member

lonvia commented Sep 17, 2018

Works for me. If I download the full relation 11153:

wget -o test.osm https://www.openstreetmap.org/api/0.6/relation/11153/full

and then run in with this sample program:

import osmium as o
import sys

wktfab = o.geom.WKTFactory()

class Handler(o.SimpleHandler):
    def area(self, a):
        print("Found area", "way" if a.from_way() else "relation", a.orig_id())
        geom = wktfab.create_multipolygon(a)
        print(geom)

if __name__ == '__main__':
    Handler().apply_file(sys.argv[1])

I get:

suzuki@loar:/tmp$ python3 area_test.py test.osm 
Found area relation 11153
MULTIPOLYGON(((12.4923334 41.8983661,12.4924989 41.8982799,12.492523 41.8983055,12.4929079 41.898105,12.4928811 41.8980764,12.4930418 41.8979927,12.4931821 41.8981419,12.493137 41.8981654,12.4932193 41.8982528,12.4932755 41.8982265,12.4935326 41.8985013,12.49361 41.8984606,12.4941137 41.8982002,12.4941928 41.8982836,12.4945434 41.898665,12.4940473 41.8989265,12.4940344 41.898913,12.4939525 41.8989554,12.4942143 41.8992347,12.4940624 41.8993119,12.4940773 41.8993314,12.4938661 41.8994396,12.4936743 41.8995412,12.4936566 41.8995237,12.4934967 41.8996079,12.4931381 41.8992234,12.4931995 41.8991914,12.4930198 41.8990002,12.4929489 41.8990372,12.4925536 41.8986167,12.4926349 41.8985744,12.4925377 41.898471,12.4924668 41.898508,12.4923334 41.8983661),(12.4926972 41.89847,12.4927723 41.8985503,12.4927888 41.8985679,12.4928326 41.8985452,12.4928035 41.898514,12.4930676 41.8983771,12.4930978 41.8984094,12.4931635 41.8983753,12.4931463 41.898357,12.4930718 41.8982773,12.4930296 41.8982991,12.4929905 41.8982573,12.4927049 41.8984053,12.4927431 41.8984462,12.4926972 41.89847),(12.4928761 41.8986582,12.4929969 41.8987848,12.4933485 41.8985987,12.4932277 41.8984721,12.4928761 41.8986582),(12.4931547 41.898925,12.4933429 41.8991276,12.4933867 41.8991051,12.4933589 41.8990753,12.4936155 41.8989432,12.493655 41.8989857,12.4937005 41.8989623,12.4935005 41.898747,12.4931547 41.898925),(12.4934353 41.8992719,12.4935371 41.899381,12.4935756 41.8993865,12.4936937 41.8993235,12.4936687 41.8992975,12.4937636 41.899247,12.4937907 41.8992752,12.4939095 41.8992119,12.4939125 41.8991828,12.4938072 41.8990701,12.4937692 41.8990664,12.4934364 41.8992392,12.4934353 41.8992719),(12.4936115 41.8986913,12.4937729 41.8988609,12.4938343 41.8988291,12.4938815 41.8988795,12.4939649 41.8988386,12.4937145 41.8985726,12.4936348 41.8986128,12.4936768 41.8986569,12.4936115 41.8986913),(12.49382 41.8985023,12.4940801 41.8987785,12.4942409 41.8986957,12.4939797 41.898419,12.49382 41.8985023)))

@lonvia
Copy link
Member

lonvia commented Nov 3, 2018

Closing as no further explanation was provided by reporter.

@Hiyorimi
Copy link

On OS X it's

wget -O test.osm https://www.openstreetmap.org/api/0.6/relation/11153/full

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants