c2h2
c2h2

Reputation: 12369

CLI to generate map tiles from osm file (open street map)?

I have tried to use Maperitive to generate map image tiles from osm files. but the process is both slow and hard to be automated.

I am look at some tools can do something like this:

mapgen planet.osm lv1-10 lat0 lon0 lat1 lon1 [some other rendering options]

where

and output to a folder contains thousands of png tile files. thanks

Upvotes: 2

Views: 3936

Answers (2)

Igor Brejc
Igor Brejc

Reputation: 19004

Based on your sample command line, I'm guessing you're trying to render using the whole planet data (planet.osm). This is not doable in Maperitive, since it needs to load the whole OSM file into memory before rendering (even if you specified only a small bounding box).

The only real way to render tiles for large areas (whole countries, continents or the planet) is to fill the OSM data into a PostGIS database and then use Mapnik to render it.

Alternatively, you could first use tools like osmosis to cut the planet.osm into a small file, but this will also take a long time.

Also be aware of the following thing (quoting myself):

Be careful when specifying zoom levels. Each zoom level needs about four times as many tiles as the previous one, so you can very quickly reach pretty large numbers of tiles which can take a very long time to generate and require a lot of disk space.

Let's say we have a map that on zoom level 10 roughly covers the whole computer screen (this would approximately be the area of London and its immediate surroundings). That means about 15 tiles for the zoom level 10. What happens if we want to generate tiles for the whole map up to the zoom level 19?

  • zoom level 11: 60 tiles
  • zoom level 12: 240 tiles
  • zoom level 13: 960> tiles
  • ...
  • zoom level 17: 245,760 tiles (cca. 80 minutes of work, cca.> 10 GB of disk space)
  • zoom level 18: 983,040 tiles (more than 5 hours of work, cca. 40 GB of disk space)
  • zoom level 19: 3,932,160 tiles (almost a full day of work, cca. 160 GB of disk space)

Upvotes: 3

Lars Kotthoff
Lars Kotthoff

Reputation: 109272

I'm not aware that any such tool already exists. You can easily adapt one of the many scripts that various projects use to generate map tiles -- most of them use Mapnik. Have a look at this Mapnik demo -- it's well documented and should be relatively easy to adapt.

Note that you'll need to supply additional parameters for the rendering (either on the commandline or in the script itself) -- most notably a style file that tells Mapnik how to render the data.

Upvotes: 2

Related Questions