TransWikia.com

How to obtain timestamp and user id from .osm file in PostGIS enabled Postgres database

Geographic Information Systems Asked by RobinLovelace on August 7, 2021

At present, osm2pgsql seems to
ignore the timestamp and user id of the elements, a serious drawback
for some applications. According to a
bug report this is not
solved by the addition of the --extra-attributes tag.
I’ve just tested this in osm2pgsql 0.83.0 and am wondering if there is a good way around it?

My plan B is to do pre-filtering with osmosis and then load the data into R using osmar. Still, it would be nice to have the PostGIS option working also.

3 Answers

The default.style file has this annotation:

There are some special database columns that if present in the .style file will be populated by osm2pgsql. These are

osm_user, osm_uid, osm_version, osm_timestamp - datatype text. Used with the --extra-attributes option to include metadata in the database. If importing with both --hstore and --extra-attributes the meta-data will end up in the tags hstore column regardless of the style file.

I have not tested it myself, but adding those tags in the style file and ommitting --hstore should work. --extra-attributes is not enough.

Correct answer by AndreJ on August 7, 2021

Maybe a heavy solution/workaround for a smal problem, but you can try to work with full planet extracts: http://wiki.openstreetmap.org/wiki/Planet.osm/full

Answered by Mapper on August 7, 2021

First, your OSM data needs user_id. Geofabrik downloads page notes this:

The OpenStreetMap data files provided on this server do not contain the user names, user IDs and changeset IDs of the OSM objects because these fields are assumed to contain personal information about the OpenStreetMap contributors and are therefore subject to data protection regulations in the European Union. Extracts with full metadata are available to OpenStreetMap contributors only.

Than you have two options:

  1. adding this three lines to style file:
  • node,way osm_user text linear
  • node,way osm_uid text linear
  • node,way osm_timestamp text linear

In this case, you don't need --hstore

  1. storing extra attributes in hstore field. First enable hstore extension in postgres database. In osm2pgsql use --extra-attributes --hstore

My code: osm2pgsql --slim --extra-attributes --hstore -c -d OSM -U user --password -H localhost -S "c:default.style" c:Europe-latest-internal.osm.pbf

Answered by Trnovstyle on August 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP