I currently use Spatialite exports from OSM data (together with Google maps like styles by Underdark) which are very useful for me as the files are easily portable with the project and I do not need Internet connection.

However, sometimes the result is a huge file - for example, my current area:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES -spat 14.20622 50.57070 17.32913 48.81776 Jeseniky.db czech-republic-latest.osm.pbf

results in about 1.7 GB file which loads slowly even on powerful machines. In fact I do not need so much detailed map data for common use.

Is it possible to create similar Spatialite file from OSM data, but with data reduced to equivalent of 1:100 000 or 1:50 000 scale?

It would be perfect and I suppose I could have whole country in such detail level for common use and sometimes only would export "full detail" area as I currently do.

is it possible?


2 Answers 2


It is not the size of the database that makes it slow, it is that you select too much to render. Simplification can be a part of the solution but it will not be enough for making you happy.

You can do lot of things once the data are in Spatialite.

  • As you suggested, simplify "update lines set geometry=ST_Simplify(geometry,0.01);"
  • Do the same but instead of updating the geometries create new simplified tables which can be used at small scale "create table simplified_lines as select ST_Simplify(geometry,0.01) as geometry,[other attributes] from lines;"
  • The same as above but filter out features which are unnecessary to show at small scale "create table overview_roads as select ST_Simplify(geometry,0.01) as geometry,[other attributes] from lines where highway in ('motorway','trunk','primary');"

Instead of creating new tables you can use spatial views but they may be slow. However, with good indexes they can be fast enough. For the previous example you would need an index on the "highway" column. What is not fun is that you should also make new scale dependent styles to suit the modified data but as Underdark has done, you can also share the result and other people can continue and improve your work.

  • hi, can you please advise me how to do this? Does it mean I put something like "update lines set geometry=ST_Simplify(geometry,0.01);" in shell + specify some target file or can I do it within QGIS? thanks
    – Juhele
    Aug 4, 2014 at 13:15
  • I would make first a backup copy of the Spatialite database and open the working copy with spatialite-gui program and run the command from the SQL window. I hope you are somewhat familiar with SQL but if not, you must learn it anyway it you are going to play with Spatialite or any other database.
    – user30184
    Aug 4, 2014 at 13:42

You can surely reduce the amount of data in the sourcefile before storing it in the spatialite database. OSMfilter or osmosis are powerful tools to filter the data.

It depends on what you are after. If you only need streets, you can drop buildings and housenumbers. In some parts of the world these take a growing part of the database.

  • in fact the best way could be if I could have almost the same the OSM website does for the 1:50k or 1:100k scale. So possibly all the types of elements but not so much detailed.
    – Juhele
    Aug 4, 2014 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.