question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create geometry from relation?

See original GitHub issue

I tried to get geometries from relations but I was getting ArgumentError for both .create_linestring() and .create_multipolygon(). I also tried both methods for each r.memberelement but with the same error. Both area and way geometries are working. Here is a snippet of my code:

import osmium as osm
import shapely.wkb

wkb_factory = osm.geom.WKBFactory()

class OSMHandler(osm.SimpleHandler):
    def __init__(self):
        osm.SimpleHandler.__init__(self)
        self.amenities = []

    def relation(self, r):        
        if 'amenity' in r.tags:
            wkb = wkb_factory.create_linestring(r)
            multipolygon = shapely.wkb.loads(wkb, hex=True)
            lon, lat = line.centroid.x, line.centroid.y
            
            self.amenities.append([r.id, r.tags['amenity'], lon, lat])
                
handler = OSMHandler()
handler.apply_file('liechtenstein-latest.osm.pbf', locations=True)
ArgumentError: Python argument types in
WKBFactory.create_multipolygon(WKBFactory, Relation)
did not match C++ signature:
create_multipolygon(WKBFactory {lvalue} self, osmium::Area area)

Is there a proper way to get the geometry from a relation in pyosmium? Thank you in advance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aginpatrickcommented, Jun 1, 2020

@njanakiev Did you find a way to solve your problem ? I need the same to build a multi-linestring from relation

0reactions
njanakievcommented, Oct 30, 2018

Thank you for clarification, @lonvia

Read more comments on GitHub >

github_iconTop Results From Across the Web

4.15 Geometric Relationships | Geometry for Modeling and ...
This excerpt from Technical Drawing with Engineering Graphics shows how to identify and specify basic geometric elements and shapes.
Read more >
Geometric (Sketch) Relations – Introduction to SolidWorks Part 1
Geometric relations are added by activating the “ Add Relation ” command in the Sketch tab of the CommandManager (Figure 2.28). You can...
Read more >
Geometric Relations - 2020 - SOLIDWORKS Help
(Dimensions/Relations toolbar) or Tools > Relations > Add to create geometric relations (such as tangent or perpendicular) between sketch entities, ...
Read more >
Create, Construct, and Query geometry Instances - SQL Server
The geometry data type provides many built-in methods you can use to determine relationships between two geometry instances. To determine if two ...
Read more >
Finding geometries with spatial relationships—ArcMap
The Geometry on Geometry check allows you to find features that are spatially ... spatial relationship, the check will create results with point...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found