NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm testing a script using PyOsmium on australia-oceania-latest.osm.pbf, though I'm planning to run it on planet.osm.pbf when I' m done.

I have printed the whole tag list of elements I could definitely find on the map, such as New South Wales, which has an admin_level tag on the website, but I can't find it when I look into the tags from my script; other tags exist and have values as expected.

Furthermore, the website clearly knows where to center the view, so it has access to the coordinates of New South Wales, but I can't find them on any tag: where am I supposed to look for them?

The files I'm using are downloaded directly from this page (Latest Weekly Planet PBF File), so I don't think any data is missing. Could it be a bug in PyOsmium?

asked 27 Jul '21, 11:22

fsaler's gravatar image

accept rate: 0%

You are likely having an issue with indirection. It sounds like you might have made the assumption that there must be nodes for everything of interest? The fact that some interesting objects have a node describing them might have led you astray. NSW is a relation ( which consists of around 700 ways ( being one) and these ways then again have nodes ( being one of thousands of nodes making up the outline of NSW).

So, what you have to do is: find relations (or sometimes ways) that have the tags you are interested in; construct their geometry by digging down into the member ways/nodes; then (if a single lat/lon is what you're after) construct a centre point of the resulting geometry.

Pyosmium can aid you in doing all this - but have you made use of that?

permanent link

answered 27 Jul '21, 11:47

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Yes, I am using PyOsmium. The issue is that I will have to do this for pretty much every single town of the planet, and constructing a centre from many related nodes of each node (or relation) sounds really expensive. Is there no way to get an approximate point more quickly? I don't need it to be precise.

(27 Jul '21, 11:57) fsaler

Apparently the Node class exposes a location property; I hadn't noticed that. I'm yet to test it, but I think that solves my problem.

(27 Jul '21, 12:05) fsaler

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 27 Jul '21, 11:22

question was seen: 1,530 times

last updated: 27 Jul '21, 12:05

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum