0

I am trying to import a PBF file using osm2pgsql, and the file looks like this:

...
node,way   amenity             text         polygon
# remove the school amenity data
node,way   amenity=school      text         delete
...

The problem is the amenity=school tags still make it in the database, is there a way to include all amenities but exclude the amenity=school tag, or should I just process it via the SQL DELETE statement in postgres?

I understand the delete flag prevents the column from being created, so this might be the reason. What are the possibilities in this use case?

1 Answer 1

1

There are a couple of ways to do this. By default osm2pgsql uses the C tag transforms, which use tag names to decide what data is imported. The C tag transforms do not operate on tag values, only tag names, so what your style file is saying is the tag key "amenity=school" is deleted, but it says nothing about tags with a key of amenity and a value of school.

Postprocessing

Running some simple SQL can remove schools

DELETE FROM planet_osm_point WHERE amenity = 'school'; DELETE FROM planet_osm_polygon WHERE amenity = 'school';

This will remove anything that is a school. It will also remove anything that is a school as well as something else, which you may not want.

Tag transforms

Osm2pgsql lets you specify your own tag transforms, written in Lua. You can find an example Lua transform included with the osm2pgsql repository. This allows you to select what you want to import, but is probably overkill for the case of wanting everything except schools.

Filtering in whatever software you are using to query

Schools don't form a significant percentage of the size of the OSM dataset. You could do a normal import, then in whatever you are using to query the database, don't select schools.

1
  • Excelent, this is what I was looking for. Thank you!
    – Mark Allen
    Commented Jul 1, 2016 at 9:30

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.