1

I have and .osm file and I would like the modify the tags based on the following criteria.

  • If highway = "unclassified"

  • and has a cycleway tag

  • Then change highway to "tertiary"

I know that with osmfilter I can modify all the "unclassified" roads

./osmfilter streets.osm --modify-tags="highway=unclassifiedto =tertiary" -o=streets2.osm

But is there a way to specify the additional criteria? Preferably a method that works on large osm files.

1

1 Answer 1

1

If it's a one-off and the file is small enough to be loaded in JOSM, one of the more popular OSM editing tools, this might be the easiest option. Use JOSM's search function (Edit > Search, or Ctrl+F) to select the correct features and edit them all at once. In your example, the search query would be highway=unclassified cycleway=*.

For large files, and as long as a bit of programming is acceptable, you could use one of the various libraries for reading and writing OSM files (such as osmium, pyosmium, osm4j, ...) to write a small script in your language of choice.

(As an aside, you may want to handle cycleway=no differently from other cycleway tags.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.