OSM dataset: are there layers?

Hi guys,
I’ve just downloaded an exerpt of the OSM dataset and imported it on PostGIS.
I understand the db is structured in nodes, ways and relations described at : http://wiki.openstreetmap.org/wiki/Database_schema

Are there **layers **such as “roads”, “hydrography”, etc?


No. Different features are identified by the ‘tags’ applied to each one. The best way to find out more is to open up an OSM editor and actually look at the data - you’ll soon get the hang of it.

(That’s for the core OSM data, of course - you don’t say how you’ve imported it into PostGIS but it’s possible that the utility you’ve used has done some processing to create layers from these tags.)


I’m looking at the data right now but the only tags I’ve found are referred to the node/way/etc author, which is a rather useless information from my viewpoint. Are there ‘standard’ tags with some semantic relevance?

Thanks again!


I think you’ve imported your OSM dataset into Postgresql, and are not using the PostGIS geo functionality. Did you load your db with Osmosis?

Usually, to load the OSM data into PostGIS for rendering on a map, a tool called osm2pgsql is used. This tool creates proper geometry objects in PostGIS, which you can then process using PostGIS functions.

Good start is to import data into PostGIS with the above mentioned osm2pgsql tool. It is done for mapnik rendering and imports only tags which have some meaning for the renderer. However, it is possible to configure which tags would be imported by editing the “default.style” file.
Osm2pgsql creates three GIS-like tables for points, lines and polygons. After that creating layers is simple either by using SQL queries directly, or by creating views into database. For example “roads” layer can be queried by
“select * from osm_lines where wighway is not null”. Hydrography is more complicated, I think it will include at least “select * from osm_polygon where “natural”=‘water’” and “select * from osm_line where “natural”=‘coastline’ or waterway=‘river’”.

Thanks for all these hints.

I’m using **Osmosis **to load these data and I managed to extract a specific layer with

select id,geom from nodes n1, node_tags t1 where t1.k = ‘highway’ and n1.id = t1.node_id

It seems to be working, but I’m sure there’s a better way of doing it.


It all still depends on what you want to do with the data.

Common way to prepare a postgis db for usage by the Mapnik renderer:

  • osm2pgsql -d gis -m -s planet-latest.gz … or whichever extract you want to load
  • psql -d gis
    gis# select * from planet_osm_line where highway is not null;

But with this approach, you’re limited to a selection of tags that are imported into the postgis db. These are defined in de default.style file of osm2pgsql. So again, it depends on your exact use case.