osm2pgsql icon indicating copy to clipboard operation
osm2pgsql copied to clipboard

Changing delete_tag rules for ingest

Open olearytd opened this issue 10 years ago • 4 comments

I'm trying to be able to ingest data keeping the note and source tags rather than dropping.

I found in multi.lua:

delete_tags = {'name_.*', 'note', 'note:.*', 'source', 'source_ref', 'source:.*',
               'attribution', 'comment', 'fixme', 'created_by', 'odbl',
               'odbl:note', 'SK53_bulk:load', 'tiger:.*', 'NHD:.*', 'nhd:.*',
               'gnis:.*', 'geobase:.*', 'accuracy:meters', 'sub_sea:type',
               'waterway:type', 'KSJ2:.*', 'yh:.*', 'osak:.*', 'kms:.*', 'ngbe:.*',
               'naptan:.*', 'CLC:.*', '3dshapes:ggmodelk', 'AND_nosr_r',
               'import', 'it:fvg:.*'}

I removed the note and source entries from the delete tags array and altered the default style to keep these tags for linear features (roads I am testing with), then rebuilt osm2pgqsl. Everything builds fine and I see in my default styl /usr/local/share/osm2pgsql/default.style that my rules kept but when I try to ingest the job dies because I am trying to keep notes in a non-delete style entry.

Default.style

node,way    note                    text    linear,nocolumn
node,way    note:*                  text    linear,nocolumn
node,way    source                  text    linear,nocolumn
node,way    source_ref              text    linear,nocolumn
node,way    source:*                text    linear,nocolumn
node,way    attribution             text    delete
node,way    comment                 text    delete
node,way    fixme                   text    delete
[centos@ip-172-31-52-70 ~]$ osm2pgsql -k -d gis source.osm
osm2pgsql version 0.91.0-dev (64 bit id space)

wildcard 'note:*' in non-delete style entry
Error occurred, cleaning up

Has anyone run into this? I've been looking around but haven't had much luck

olearytd avatar Oct 24 '16 13:10 olearytd

Maybe this is what I need

http://gis.stackexchange.com/questions/200570/osm2pgsql-style-removing-amenity-school-but-keeping-the-rest-of-amenities

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.

olearytd avatar Oct 24 '16 14:10 olearytd

With the C transform (the one that uses the default.style config) you cannot have wildcard entries like note:* because osm2pgsql would not know in which column to put the data. 'note' will work without problems. If you want to keep all notes, you should use completely remove the note entries in the style and then use one of the hstore options. This will keep all tags that are not marked as 'delete' in the style file in a hstore column, among them all 'note:*' tags.

lonvia avatar Oct 24 '16 19:10 lonvia

Oh awesome! I'll try that out. Thanks for the reply and I'll close the ticket if that works out for me

olearytd avatar Oct 24 '16 19:10 olearytd

I removed the delete tags and used -k option during ingest for hstore.

Doing a test, it looks like my database now captures all of my source:* options. Thanks @lonvia !

olearytd avatar Oct 24 '16 19:10 olearytd