2

When I export a svg file I get some wrong rendering, like maps exceeding their frame, grid lines that are supposed to be disabled, and inconsistent line styles. This happens only when exporting in vector, rasters are perfect as seen in the composer preview.

What could cause this?

raster image

vector image

  • I can confirm this. QGIS produces a warning that this kind of bug is related to qt4 svg code. Now that QGIS 3 is based on qt5 I hope this malfunction can be addressed. Let´s hope so at least! – hilpers Feb 10 '17 at 8:53
3

This is a known issue https://hub.qgis.org/issues/159 which is related to Qt if I remember correctly.

Maybe the move to Qt5 for QGIS3 will help.

1

Seems not to be related to qt4 exclusively. I just installed the latest master version (2.99) and this behaviour can still be observed.

1

This issue goes back a long way... in fact there's a dialog which warns you about this very problem whenever you try to export to SVG (the problem is in Qt)

However it IS possible to work around this. It won't work like an overview, though, so it's not suitable for 'atlas' functionality, I'm afraid. It is tricky and involved. You will probably end up swearing. But it can be done.. here's an example in Inkscape, exported from qgis :)

enter image description here

You can do this by adding two clipped maps, one main one, one inset, and setting the extents manually in composer.

I've only ever tried this with WGS84. Your mileage may vary depending on projection being used. I suspect UTM may be okay but anything with curved meridians won't work.

Manually setting extents and zoom levels

You need to work out the extent you want for the inset map, and meticulously clip the polygons to that extent. This needs a bit of planning, like knowing the zoom level, and it's easier with some projections than others.

  • Zoom in to the area you want as the extent of the inset map.
  • Make a note of the zoom level
  • Use the processing algorithm Clip Vectors by Extent. Choose the canvas extent.
  • You should now see something like this.

enter image description here

There, the brown represents the larger area (the inset/context map). The blue represents the zoomed-in area.

  • Use metadata to get min/max extent of clipped layer e.g. xMin,yMin -29.4264,-20.1055 : xMax,yMax 18.7455,26.9695
  • turn off all layers except the clipped one.
  • add a new map. shape doesn't matter as the next two steps take care of this.
  • copy and paste the scale into the Composer item settings
  • copy and paste these 4 values (xmin, ymin, xmax, ymax) manually into the extents on the Composer Item settings. Don't use set to map canvas extent. It's tempting, but it may break things.
  • Add a frame (if needed), grid etc.
  • Lock layers (optionally, Lock style for layers)

repeat this process for the map zoomed in (making sure you turn off the clipped layer this time). You can use Layout > Send to back to slide it under the inset map.

Finally, export as SVG from composer. You might find it helps to use the clip to content option here.

Not quite sure how to get the 'highlight' to appear inside the inset map, but I hope this gets you closer to the output you're after.

1

In addition to all these other answers - a good workaround is to export the maps to pdf instead of svg. Almost all svg editors will be able to import pdf files and this issue ONLY exists for svg export.

  • That's what I do as well, svg would be more flexible though. So the svg issue related to qt4 remains in qt5 and hence qgis 3? – hilpers Feb 11 '17 at 11:05
  • Yes, it's still an issue – ndawson Feb 11 '17 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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