2

Given a vector line and symbology settings as a simple dashed line (in QGis v3.4.3): enter image description here

As I understand the QGIS concepts there is a difference between a line (feature) contained on a vector layer and its representation as defined in the layer properties (under Symbology). But I would like to get the outline of this dashed line (as configured in the symbology of the vector layer) as a set of polygons (may be multipolygons or similar) on a new created vector layer.

For a solid line I would use the tool buffer from the vector geometry toolbox to "convert" a vector line to a polygon representation of an outline with a certain width.

Is it possible to convert/transform/"bake" (whatever the name is) a symbology (out-)line into a vector layer like polygons or multipolygons?

jGaboardi
  • 125
  • 1
  • 7
Athomi
  • 23
  • 3

2 Answers2

0

You can follow this steps to get symbology into DXF. After it is possible to import dxf back in to QGIS or use it in some other software.

Mat
  • 1,588
  • 1
  • 8
  • 18
  • Your proposal would be a more straight approach but i didn't manage to reimport the exported DXF file back to the QGis correctly so far. The dashed line was reimported as a solid line and not as a dashed line. Maybe i did something wrong with the parameters for the DXF export. Thanks anyway – Athomi May 14 '19 at 20:25
  • Ja, there are some tricks in exporting dxf, maybe i'll look into it when i have some time und update. May i ask what is the reason for this. I am sure there there are more appropriate, simpler and precise ways to achieve what you need than rasterizing map or daeling with DXF export-import. – Mat May 15 '19 at 04:51
0

This isn't perfect, but it's about the only thing I could find that approximates what you're asking.

  1. Adjust the symbology of lines_layer to your liking. In order for the next step to work, make sure that your symbology is based on Map Units.

line styled by map units

  1. In the Raster tools toolbox, select the tool Convert map to raster. Set the parameters as follows and run the tool:

    • Extent: Slightly larger than lines_layer, so as not to clip the output.
    • Map units per pixel: This will depend on the symbol size of your line. In my example, I chose a value that was 5% of the line width.
    • Make background transparent: checked
    • Single layer to render: lines_layer

Below is one line dash in transparent yellow, with the rasterized version of the same dash in B/W.

rasterized line dash

  1. Run Polygonize (Raster to Vector), found in GDAL > Raster conersion, on your newly-created raster.

If you've got any angled lines, you'll end up with a bunch of jagged polygons, as shown below.

vectorized rasterized line dash

  1. You'll need to run a tool to straighten out the edges of these new polygons. There are a couple of things you can do:
    1. Simplify. You may need to toy around with the tolerance parameter a bit, but I had satisfactory results with 10% of the line width. Some dashes may have more than 4 vertices, however, resulting in some polygons being misshapen.
    2. Oriented Minimum Bounding Box. This method results in polygons which are all perfectly orthogonal, but each one may be at a slightly different angle from its neighbors.

Below are the different vector stages of this process. Which you prefer is probably dependent on what exactly you need these dash polygons for.

outputs

jcarlson
  • 3,880
  • 1
  • 13
  • 34
  • 1
    Your approach will work for me. I would prefer a solution directly to a vector layer but by converting into a raster layer and then back as vector layer is working. Thank you for your detailed explenation – Athomi May 14 '19 at 20:20