NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I noticed that the recommended command to import data into the postgresql database from the tutorial here


osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2500 --number-processes 1 -S ~/src/openstreetmap-carto/ ~/data/azerbaijan-latest.osm.pbf

which lists the openstreetmap-carto style file. The recommended import command for OSM-Bright from


osm2pgsql -c -G -U postgres_user -d postgis_database data.osm.pbf

My question is do I need to re-import the raw OSM data into the postgresql database everytime I want to change map styles and specify it during data import? The first tutorial specifies a style in the import command while the OSM-Bright tutorial does not. Thanks for any help.

asked 13 Sep '18, 22:25

coderunner's gravatar image

accept rate: 0%

Short answer: Yes. There is no need to reimport data.

A style file for osm2pgsql specifies aspects of how osm2pgsql converts OSM data into PostgreSQL tables, how much data is transferred from OSM xml into Postgres database. For example if a style does not display some kind of objects (powerlines, sidewalks etc) there is no much sense in keeping them in the rendering database. By constructing custom style you can filter what objects to include. More on this can be found here:

Now to compatibility of for OSM-Bright. Though default style that comes with osm2pgsql imports more data comparing to openstreetmap-carto (you can take diff of these two styles to see what objects are filtered) OSM-Bright does not use these data. So you can safely use the OSM-Bright style on the same database you made for openstreetmap-carto style. You can look at layers that are used by OSM-bright in this file - look for SQL statements. This is how data is queried from Postgres to Mapnik for rendering.

permanent link

answered 18 Sep '18, 09:44

getmaps_io's gravatar image

accept rate: 100%


Makes sense, thank you for the explanation of what's going on under the hood. That was very helpful.

(18 Sep '18, 16:30) coderunner

Probably yes. Rendering database is a special purpose database derivative and this can be very different for different styles.

One can make some mappings, but it needs some knowledge about SQL.

Quite simple solution (if you have enough of disc space) is to have more databases and just switch them - this is my rough script for this purpose (gis is default database, gis2 is the second one):

sudo service postgresql restart
sudo -u postgres -H -- psql -c "alter database gis rename to temp;"
sudo -u postgres -H -- psql -c "alter database gis2 rename to gis;"
sudo -u postgres -H -- psql -c "alter database temp rename to gis2;"
permanent link

answered 13 Sep '18, 22:43

kocio's gravatar image

accept rate: 20%

edited 14 Sep '18, 03:29

That is a good idea. Thank you.

(18 Sep '18, 16:30) coderunner

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Sep '18, 22:25

question was seen: 4,947 times

last updated: 18 Sep '18, 16:30

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum