0

Is there a way to use osm2pgsql and have it only keep features that have values for certain attributes?

For example, only keeping features which have a value (i.e. not null) in the default highway column?

I saw in the manual that you can use --hstore-match-only, but I would like to skip the hstore column completely, and simply only import features for which the highway column will be non-NULL

1 Answer 1

3

If you can code, I can really recommend you to use the osm2pgsql flex output. In the osm2pgsql repository is an example for your highway requirement.

If you just want an easy solution, you can first filter your osm file with Osmium and then upload it to the postgres database with osm2pgsql:

osmium tags-filter rome.osm.pbf w/highway -o highways-in-rome.osm.pbf

or

osmium tags-filter rome.osm.pbf w/highway=primary -o highways-in-rome.osm.pbf
1
  • I forgot about osmium! Thank you, it works perfectly. I don't have any experience with Lua unfortunately, but the osmium solution works great.
    – wfgeo
    Jun 20 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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