osmcode / osmium-tool

Command line tool for working with OpenStreetMap data based on the Osmium library.
https://osmcode.org/osmium-tool/
GNU General Public License v3.0
483 stars 104 forks source link

osmium extract keeps some ways outside of the polygon #257

Closed andrzejkurczewski-tomtom closed 1 year ago

andrzejkurczewski-tomtom commented 1 year ago

What version of osmium-tool are you using?

osmium version 1.14.0 libosmium version 2.17.3

What operating system version are you using?

CentOS Linux 7

What did you do exactly?

I downloaded the Planet PBF from https://planet.openstreetmap.org/ I used osmium to extract Croatia using complete_ways strategy:

osmium extract --strategy complete_ways -c extract_config.json input.pbf

where config is as follows:

{
  "extracts": [
    {
      "output": "HRV.osm.pbf",
      "output_format": "pbf",
      "polygon": {
        "file_name": "HRV.geojson",
        "file_type": "geojson"
      }
    }
  ],
  "directory": "(...)"
}

Find geojson attached: HRV.zip It should be the same as country boundary in OSM, but it has a few months already.

What did you expect to happen?

I expected an output file to contain ways and nodes located in or crossing the Croatia border.

What did happen instead?

There are ways outside Croatia (located in Slovenia, Italy and Austria) included. Below you can find the resulting PBF filtered with osmfilter for highway=path only, for easier visualization: complete_paths.zip And the visualization: unexpected_paths

Sorry for such large-scale example. I failed to reproduce this issue when extracting smaller areas. However, it did reproduce for multiple country polygons, including Austria, Czechia, Greece, Hungary or Italy.

In all cases the unexpected ways seem to cross the north edge of the country bounding box.

joto commented 1 year ago

I can reproduce the problem, so there is definitely a bug there. Looks to me like some rounding problem at the bounding box edges or so. This needs some investigation.

andrzejkurczewski-tomtom commented 1 year ago

Maybe one more useful remark - it seems the problem doesn't occur with simple strategy.

joto commented 1 year ago

@andrzejkurczewski-tomtom Are you sure? When I tested it, it happened with the simple strategy, too.

andrzejkurczewski-tomtom commented 1 year ago

Croatia (exactly the same geojson) was the only country I checked with simple:

osmium extract --strategy simple -c extract_config.json input.pbf

And that was my result: image simple_paths.zip

But of course I cannot be sure it won't happen for simple for any other input.

joto commented 1 year ago

I believe this is fixed in the current master. Can you check whether it works for you?

joto commented 1 year ago

No feedback, so assuming this has been fixed.

andrzejkurczewski-tomtom commented 1 year ago

Hi @joto, sorry for the late response. I can confirm it works for me with 1.15 release, thanks a lot!