openstreetmaposm.pbfosmium

Can't find data for OSM Way ID 404140216 from downloaded PBF file using Osmium


I'm having trouble extracting data for a specific way (ID: 404140216) from an OSM PBF file I downloaded from Geofabrik: italy-latest-internal.osm.pbf.

I tried using Osmium to extract the data for this specific way using the following command:

osmium getid --output-format=xml italy-latest-internal.osm.pbf 404140216

But the result I get is only the bounding box, and not the actual data for the way. The output looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="osmium/1.17.0">
  <bounds minlat="35.07638" minlon="6.602696" maxlat="47.100045" maxlon="19.12499"/>
</osm>

However, when I check the OSM website for the way ID 404140216, I can see there is data.

What I've tried:

  1. I downloaded the italy-latest-internal.osm.pbf from Geofabrik.
  2. I used osmium getid with the specific way ID.
  3. The result only shows the bounding box, no data for the way itself.

Question: Why can't I extract the actual data for this way using osmium getid? How can I extract the detailed data for this way from the downloaded PBF file?

I would appreciate any help or insight into this issue!


Solution

  • The description for osmium getid says:

    On the command line or in the ID file, the IDs have the form: TYPE-LETTER NUMBER. The type letter is ‘n’ for nodes, ‘w’ for ways, and ‘r’ for relations. If there is no type letter, ‘n’ for nodes is assumed (or whatever the --default-type option says). So “n13 w22 17 r21” will match the nodes 13 and 17, the way 22 and the relation 21.

    Since you want to obtain a way, not a node, you have to specify the element type. To specify the type, either use --default-type=way or w404140216.

    Note that OSM IDs are only unique within a certain element type. In other words, a node, a way and a relation can share the same ID. Therefore it is important to specify the type of the element you want to retrieve.