export-svg Command


Exports the current map to a SVG file.


   [file=<output file>] 
   [map-scale=<map scale>]

All parameters are optional:

The command records a list of generated files. This list can be automatically forwarded to subsequent file commands like ftp-upload Command and zip Command.

Exporting And Bounds

export-svg Command does not cut the data exactly along the export boundaries. So, for example, any OSM ways that extend outside the boundaries will not be cut. However, the exported SVG file specifies the clipping rectangle for the actual area specified by the user, so the data outside of the user-defined boundary will not be visible.

Exporting And Bitmaps

The exported map can contain bitmaps. export-svg Command treats bitmaps in two ways:

When copying images, the command makes sure the images do not overwrite each other if they have a same name (this is especially problematic for web tiles). The command adds suffixes like .1 or .2 to duplicate file names.

Making SVG Exports Portable

If you want to copy your SVG export to some other computer or send it via Internet, it is suggested that you:

  1. Set the copy-images to true.
  2. Export the SVG to a separate (empty) directory.
  3. Zip all the resulting files in the directory into a single ZIP package which can be easier to move around.


Due to the pretty buggy support which Adobe Illustrator provides for loading SVG files, it is not possible to have the same SVG optimally shown in both Illustrator and Inkscape. In other words, if you plan to use the SVG file in Illustrator, you should specify compatibility=illustrator parameter. Maperitive will in this case do some tweaks to the SVG file which allow it to be shown without any problems in Illustrator (tested in CS5). But do not expect this file to be usable in other SVG viewers/editors.

On the other hand, if you need a SVG file which can be shown in various Web browsers and editable in Inkscape, you should specify compatibility=inkscape parameter. Again, do not expect this file to be usable in Illustrator.

Precision Typography

When rendering text on paths, Maperitive positions and renders each character separately to achieve the best effect. This is called precision typography.

The problem with precision typography in the context of SVG is that other software usually treats such text labels as a series of separate text elements (one element for each character). This can be a problem for big maps - see the Troubleshooting section below.

Precision typography is turned off by default, in which case SVG text elements will not be broken into individual characters. Instead, a text label will be broken into one or more parts based on the rotation angle of each part.

Not using precision typography can produce some irregularities in how the text is rendered, usually in form of poorly spaced characters. This can be corrected manually in the SVG editor, but if you want to avoid this, try turning on the precision-typo parameter and pray that your map can be loaded in the SVG editor.

Current Limitations

Some SVG renderers (like Inkscape and Illustrator) do not have a good image scaling algorithm, so certain bitmaps can appear rather grainy (see the example of hillshading below) compared to how they look in Maperitive. I will try to implement an automatic rescaling for SVG exports in the future.


The generated SVG cannot be loaded into Inkscape/Illustrator

There is a limit of what both Inkscape and Adobe Illustrator can import. Although SVGs generated by Maperitive are usually not very large (up to 10 MB of file size), the file size is not the real indicator of whether these programs can "swallow" your map or not. The principal guideline is the complexity of the map: how many graphical elements it contains.

From my experience the biggest bottleneck is the number of text elements on your map. As an example I worked on a city map for Dublin, Ireland which contained around 25,000 individual text elements. This number can become large because street labels tend to be broken into several separate text elements due to the fact that Maperitive has to render each letter separately for very winding roads.

The sheer number of text elements proved to be a problem for me - my map would not load either in Inkscape or in Illustrator. There are several solutions for this problem, but none of them is an ideal one:

  1. Turning off precision-typo parameter. See the above section about precision typography.
  2. Reduce the number of text elements. In my case that would mean hiding certain less important street labels.
  3. Split the map into several geographical parts. Initially I wanted to have the whole Dublin and its surroundings as a single map, but in the end I had to split the map into several parts.
  4. Separate painting stages into several SVG files. Using MapMaxPaintingStage (TODO), MapMinPaintingStage (TODO) and MapHiddenPaintingStages (TODO) settings, you can render painting stages as separate SVG files and then glue them together in the editor (that is if you manage to load them all). I tried experimenting with rendering text labels into SVG separate from the rest of the map elements.

The generated SVG is shown off-center in Illustrator

Adobe Illustrator has a limit of 16345 pixels for the width and height of its canvas (a.k.a. artboard). Maperitive by default uses 1:1 scaling when rendering SVG elements, so the actual coordinates of elements correspond to those on the screen. If your map is very large, it could exceed this limit. There are two ways to solve this:

  1. Set the scale parameter of the export-svg Command to a value between 0 and 1. This will not have any visual effect on the map, but it will shrink all coordinates based on the scale factor you set. But unless you know exactly what the scale factor you need to shrink everything to a 16345x16345 box, use the second option, which is to...
  2. ...set the ai-autorescale parameter of the command to true. In this case Maperitive will calculate the needed scale factor itself and rescale the map accordingly.

See also: