QGIS User 0030 - Working With SVG

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this episode is focused on svg markers that can be modified and used in qgis [Music] so first of all there are some differences between markers in svg format and in kyogis and it has to do with how colors and outlines are handled so in svg we have fills with opacity those parameters control the fill in each of the vector objects in the in the file then we have stroke and that is the stroke outline color stroke width and stroke opacity and those three control uh the outlines for the shapes in the svg format qgis have equivalent parameters for controlling markers and shapes for as fill and fill opacity and it has outline for the color and outline with an outline opacity so when we are talking about stroke it is svg and outline it's in kyogees in the svg format we can override the default or the decided properties for these parameters with a parameter so we can assign the fill in the svg the parameter fill from qgis and that works great for simple vector shapes like this ellipse but if we have more complex svgs for instance with more than one shape like this we can only control the fill from kyogis once so we can assign the kyogi's fill color to both of these shapes but we can't assign a fill color to a different fill color in kugi's however we can assign two colors in qgis for the fill and for the outline so technically we could use the fill for the ellipse as the fill in kyogis and the fill for the rectangle as the outline color and that way we can control two fill colors in the svg marker so that is what i'm going to play with in this episode and show you how you can do it yourself so i'm going to try and create a match in inkscape and it will have a flame that i want to control with the fill color in kyogis it will have a flame core or a center that will be a brighter version of this flame color it will have a match head it will have a stick and the stick i want to control with the outline color and the stick will also have a highlight that is a brighter version of the stick color and i will also add an outline to the stick that will be controlled at least in some way so let's switch to inkscape so inkscape is a free an open source vector program and you could probably do this in illustrator as well i like to use inkscape so that is what i'm going to use and if you want to be good at inkscape it can be a bit confusing from time to time but there are plenty of good really good tutorials on youtube logos by nick is one that i really like so i will try to keep this simple but if you don't completely understand what i'm doing then you probably need to look into some tutorials about inkscape because this is not a tutorial tutorial about inkscape so first of all we navigate much the same as in kyugis pan by pressing the ctrl l zoom wheel on the mouse and we can zoom in and out by holding control the control button down if we just scroll the wheel we pan and with shift and scroll we pan horizontally but that's not important so first of all i will start by creating the stick and i use the rectangle tool for that and let's make it red so like that and right now it has rounded corners so i need to change the handles here like that and i will switch to the select and transform tool i can do that by pressing s on the keyboard so that is probably okay for a matchstick uh i will also want to check my outline so down here we have a colors and you can use the scroll wheel to see the presets but you also have a fill and stroke panel and you can access that with a button up here so first of all let's change the field to something more match stick like that's good enough and the stroke should be black the width should be a bit bigger that looks okay uh i want the stroke to be underneath the fill so for that i can look here stroke fill markers that will put the fill underneath like that now i want to create the highlight so i duplicate this and can probably do that through the menu but i use ctrl d to duplicate let's put that in a different color make it a bit smaller remove the outline and the fill should be white with about 40 opacity like that that's a good enough for a stick before i move on i want to name this rectangle the stick not the highlight the stick rectangle and i do that by looking at the object properties so instead of this generic rect830 i will call this stick and it's important to press enter here to confirm that it's edited otherwise it will be lost so now i can see it it's stuck so the matchhead another rectangle should be black and this should be a bit rounded like that and right now it's a rectangle but i want to change that to more more uh manageable or a pliable form so let's change that object to a path and that will remove the possibility to modify it as a rectangle so now it's more a vector shape so i move these two corner vertices in a bit so i get a different shape for this the color should be black as i mentioned but it should not have any opacity so go to fill and stroke and make it fully opaque that's a good enough match and i will call this with the object properties head don't forget enter and now for the flame i will use the bezier pen bezier pen and i will use the b spline method for the pen the default is just a regular bezier but i will use b-spline so starting oh turn off the snapping starting here about here i will to a shape like this and in the top here i don't want it to be a this ear curve so i hold down shift when i press the last vertex and then i release shift and i can continue with my shape and click on the first vertex to close it how i can move it around a bit yep that it will probably do not a perfect shape but anyway a yellow fill remove the outline and now i want to create the the core of the flame so i use duplicate command ctrl d make it red and then i want to make it smaller and then there's a inset command ctrl left parenthesis so i press that repeatingly to get it to smaller size like that mark them both put them underneath the flame and this should not be an opaque color it should be white with opacity maybe 50. let's try different colors so when i later changed the flame color in kyugies the core color will adapt to it like this so as a default let's leave it at that and the flame i want to rename that as well object properties call it flame don't forget enter and then i have one shape here called flame i have the flame core i don't care about changing the name for that i have the matchhead and that should be black with no outline i have the match stick name stick i have the stick highlight and i have an outline for my matchstick and it's beneath everything so that is good enough as a match right now the svg extent is this page size so to resize that we can go to the document properties and that is a link up here and in that we have this resize page to content drop down and uh here's a button that we can press to resize it there's also a keyboard shortcut ctrl shift r so now the extent of the svg is exactly the shape of the my graphics my object and now i see one potential problem and that is the extent ends very close to the stick so if i make the outline wider let's see where do we have it feel and stroke stroke width let's increase that a lot like that you see it sticks down beneath the page so i will redo the page size with a larger um outline so ctrl shift r like that and then i can make this stroke smaller again one like that that will leave me room for using this that is one way to do this another way and i will probably show that instead so resize it again now it will be clipped never mind forget everything i said okay that completes my marker so let's save it as a match match and we can leave inkscape to modify the svg so it can be used in kyogi's we need to add the parameters that i started with so i need to open it the svg in a text editor in the svg file there are a lot of code and you can skip that for the most part it has information about the software that were used to create it and those are only specific to inkscape in this case so if you open this in illustrator illustrator we'll just ignore this and then we have more information and then we have the metadata and that depends on the settings in your software in this case it has my name as a creator and it has a license for the graphic and i can skip that as well and then we come to the path uh for in this case the flame and there's a lot of coordinates in a lot of ways and you also get a style parameter and this is the default colors and style parameters that were set inside inkscape we will override that with our own parameters uh we have the flame and there's another path with a random number now we have a rectangle that is the stick and we have a path that is the head so now we need to modify the flame and the stick so let's start with the flame so look for the flame path and directly after the path just insert a row and i want to control the fill color so fill equals param fill like that that takes the fill parameter from kyugis and applies it to the fill of this path and i also want to control the opacity of the fill so opacity param like that now i can control the fill for the flame by the fill color in qgis let's see where's the stick here we go the stick and that's a rectangle so let's add a fill or the stick that should also be a param but it should not be the fill it should be the outline so the kyogi's outline color should be applied to the fill color in the svg and the opacity for the stick fill should be param outline opera city and i also want to control the outline for the stick so that is called stroke but i can't control the stroke color because that is uh used for the fill color so i can only control the width and that should be param outline width and i can control the outline color outline opacity color outline opacity and that's stroke opacity param outline opacity like that and the rest i just ignore because i don't want to change the colors or anything else in the file so i leave the default ones there so just save and let's open qgis so here i have a point layer with simple markers let's change that to svg markers and get the match svg make it bigger let's magnify it so you can see it clearly so here i have the by kyogi's assigned colors so let's make the flame which is the fill color yellow and the stick brownish like that outline no stroke or yeah the opacity here it doesn't work as intended because it will also affect the fill color so it will not affect the outline color so we can forget about the outline opacity so let me just change that so the rectangle stroke opacity can remove that that was unnecessary save it jump back and i need to re open the svg oops there we go like that so the opacity now only should control the fill but it doesn't so depending on your settings the effect these colors have will vary so it will in the end be a combination of qgi settings and inkscape settings but this way you can control the flame color and opacity and you can control the stick color and opacity but when we combine that with the stroke there will be some issues because they are connected so for the fill if you can don't use opacity and now we see the outline here it's clipped can you see that the outline for the stick is clipped at the bottom of the uh shape for the stick and that is because the svg page is defined to end here we can get around that inside qgis and that is by rotating it rotate it by a very small amount like that you see now suddenly the size of the page for the svg is ignored but if we leave it at zero rotation it will be clipped i'll just keep it at a very small outline when you work with svgs there's a huge benefit to working with svgs and that is you can share your style really easily so instead of just referring to an svg file you can use the embed file function so by embedding the svg it will be included in the style file so if i want to share this match i can just save the symbol i'm sorry you can't see the dialogue i'm just typing in match like that and now it is in my style manager so i created it in a test tag with a test tag so yeah here i have my match and now i can export items i can select by group test and it's also let's see if you match there selected and i can export it to a match xml file and this xml file can be sent or shared with anyone and all they need to do in return is to import the items i have created a lot of styles recently and i put them on github and i will leave a link to a collection of styles there and that url you can just copy it and then in qgis in the style manager you go to import and then instead of file you select url and you just paste the url to from the description click fetch items you get a lot of styles you can select them all or individually and import i already have them all but let's import them and then you get a few more styles that i've created recently so hopefully uh that will inspire you to create svg styles and the styles if you download my styles a lot of them are actually based on sv embedded svgs so for instance if we take random let's see random i have a the matches off an ink style let's bring it to 100 pen pencil sharpie moss and all of these are not all of them but most for instance is an svg marker line with an embedded svg file and i also have a few other styles and in some cases most of them they are also embedded svgs in some cases they are just simple markers but in many cases they are embedded svgs so hopefully you have learned something about svgs and how you can incorporate them into qgis and it's really a great way to get complete freedom when it comes to symbology in yogi's see you next time [Music] [Applause] [Music] you
Info
Channel: Klas Karlsson
Views: 4,356
Rating: undefined out of 5
Keywords:
Id: 6ZNesLmaJ0M
Channel Id: undefined
Length: 32min 45sec (1965 seconds)
Published: Sun Jul 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.