Do you want to create your custom map label(s) for your QGIS map? Map labels are also called map symbols or markers. QGIS comes with an extensive number of markers for you to use in your maps. However, there are always instances when none of these inbuilt symbols fit the theme of your map. In this article you’ll learn how to create your own custom and editable map labels using Inkscape.
Inkscape, like QGIS, is a free and open-source software. Inkscape is a vector graphic design software. It has all the features you need to create any map label of your choice. This tutorial will show you how to create editable marker(s) for your map using Inkscape. It will also show you how to import the marker(s) into QGIS.
This tutorial doesn’t cover how to draw lines, shapes and curves in Inkscape. So, if you are new to graphic design or you have never used Inkscape then you might want to learn the basics of graphic design and some Inkscape tutorial.
Message to Non-Inkscape Graphic Designers
This tutorial will be based on Inkscape, so if you are not able to follow along in your software then you might want to switch to Inkscape. Those who already know how to use a design software such as illustrator can simply follow along. Also, ensure that your design software is able to save files in the SVG format. I’ve once read that Corel Draw has poor support for SVG. In fact, I once designed a business card for a friend -in SVG format- only for him to be unable to print it because the printing guys only use Corel Draw.
That said, you can download the latest stable version of Inkscape (at the time of this writing) here. Or go to inkscape.org and click the download tab from the top menu. I’m assuming that you already have QGIS installed on your computer, if not then click the download button on the QGIS homepage. Lastly, if you already have the two -Inkscape and QGIS- installed on your computer then please follow along as we create our custom SVG markers with Inkscape and import it to our map in QGIS.
Launch Inkscape
Once you have downloaded and installed Inkscape on your pc, the next step is to launch the software. Simply double click on the Inkscape logo to launch it -just as you would launch a typical software on windows or mac.
Draw your marker
Draw your icon or symbol using the Inkscape drawing tools. Don’t bother about the size of your drawing.
Also, ensure that you align your drawing to the centre of your page.
Lastly, Inkscape saves in the SVG format –which is a vector format- so the length or width of your drawing has no significance, at least not now.
Slim-fit your page to your drawing
Now that you have drawn your map symbol. The next step is to set the page size of Inkscape to the size of our drawing. If you don’t do that QGIS will think your whole canvas is your marker. Trust me you don’t want that. However, you’re free to experiment and checkout the ugly result.
Those who are familiar with Inkscape might think that they need to go to File > Document Properties, manually input the page size then centre their drawing on the page.
While that might work (fine or not), it’s an unnecessarily long journey. Inkscape has a cool feature that lets you automatically resize your image to the size of our drawing. I call it slim-fitting your page to the size of your image. To access this feature follow these two simple steps:
a. Click and drag you mouse across the screen to select the object(s) that you wish to use as your custom marker in QGIS.
b. Go to Menu > Edit > Resize page to selection. Alternatively, you can use the Ctrl+Shift+R shortcut on your keyboard and your page will resize itself to fit the objects you have selected.
Save your drawing to Scalable Vector Graphics (SVG)
Now that you’ve successfully created your map symbol and slim-fitted your page to the size of your map label. The next step is for you to save your drawing as SVG. More about SVG here and here.
Go to File > Save as or use the Shift + Ctrl +S shortcut on your keyboard to open the save dialogue box.
A dialogue box will appear. Here you will choose the directory you wish to save your drawing to, the name you wish to give your icon and the format you wish to save it to.
SVG is Inkscape's default format. Just as QGIS works with QGS/QGZ, Photoshop with PSD and Microsoft Word works with DOCX.
To be on the safer side, I advise you not to save in the default SVG format. So please choose the option next to it; PLAIN SVG. Choose PLAIN SVG, then click on save.
Make your marker readable for QGIS
Your marker is now ready to be used in QGIS. However there is a ‘but’, Right now, QGIS cannot edit the fill colour and stroke colour. So also QGIS cannot read the stroke width. As a result, QGIS will not you the option to edit any of the above properties of your map symbol. This means you have to repeat all the steps above every time you feel like changing the size or colour of your label. If you have no resentment for this repetitive task then you should consider another career outside tech.
If you are new to Inkscape, stroke means the outline of a shape and fill means the colour of the inside. The rectangle above, for example, has a red fill and blue stroke.
To make your SVG marker editable in QGIS you need to access the code of the SVG and edit some lines. Don’t panic yet, it’s simple and straight forward. But before proceeding it is a good idea to keep a duplicate of the file just in case mess things up.
Any text editor will do but I'll use Notepad++.
Open the directory where you saved your plain SVG
Right click and choose edit with notepad++ or edit with notepad.
Now, look for the line of code that begins with style. You can search for it by using CTRL+F and entering “style” in the text box.
Select and delete the line of code that begins with “style”.
It should look like this:
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:none;stroke-width:0.09393167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.57435901"
Then replace it with this line of code:
fill="param(fill) #fff" stroke="param(outline) #000" stroke-width="param(outline-width) 1"
Now click CTRL+S to save your edit.
Import you marker to QGIS
You are almost done. This is the final step.
Launch QGIS and add your shapefile to the QGIS canvas. Right click on the layer of your choice in the layers panel and choose properties. Then click on the symbology icon.
Click on the ‘symbology layer type’ drop down menu and choose SVG markers. QGIS will load the inbuilt SVG markers. You want to use your custom marker which you created in Inkscape not the inbuilt markers. To do this scroll down to the bottom of the dialogue box and click on the button with three dots. Navigate to where you saved your custom SVG marker which you edited with notepad++ (or your favourite text editor). Select the SVG icon and click on open.
Ensure that you set your vertical and horizontal anchor points to Vcenter and Hcenter respectively.
That’s it. You’ve added your custom SVG icon which you made in Inkscape to QGIS.
Were you able to add your custom SVG icons which you made in Inkscape to QGIS successfully? Did I omit any part or didn’t explain something clearly? Also, if you encountered any challenges kindly let me know and I’ll be glad to give a helping hand.
I’ll be glad to hear your feedback.
Follow Me