Skip to content

Instantly share code, notes, and snippets.

@kgjenkins
Last active February 20, 2020 21:06
Show Gist options
  • Save kgjenkins/e1ab20e850f365a94e781d2927fbfd61 to your computer and use it in GitHub Desktop.
Save kgjenkins/e1ab20e850f365a94e781d2927fbfd61 to your computer and use it in GitHub Desktop.
Paint splotch icons in QGIS

Paint splatter icons in QGIS

QGIS has the ability to style points using SVG symbols, and size and color them by attributes of the points.

SVG is a file format that means Scalable Vector Graphics. Because they are a vector format, they can easily be sized without losing detail or becoming pixelated (as can happen with raster icons).

Free or public domain SVG files can be found on the web. For example, here is a collection of paint splatters: https://svgsilh.com/tag/splatter-1.html

SVG files are actually text files that can be viewed in any text editor. Many SVGs are solid black; if you want to be able to color them in QGIS you'll want to edit the SVG and change fill="#000000" to fill="param(fill)" -- this has already been done for splatter1.svg -- click the "raw" button below to see the SVG code.

Use a SVG marker in QGIS

Below is a sample point file called points.geojson. Load it into QGIS. First, we'll style it with a generic splatter symbol.

  • Open the Layer Styling panel
  • Click "Simple marker"
  • Change "Symbol layer type" from "Simple marker" to "SVG marker"
  • Scroll down, past the built-in SVG Groups and click '...' to select the splatter1.svg file

The markers are probably to small to see, so scroll back up, above the fill color and set:

  • Width = 15 (millimeters)

image

Notice that the splatters look way to similar, so we'll apply some random rotation:

  • Next to the "Rotation" input, cilck the icon on the right (for data-defined override) > Edit
  • Enter the expression rand(0,360)

image

Let's style the symbols by the population:

  • At the top of the Layer Styling panel, change "Single Symbol" to "Graduated"
  • Value = POP2000
  • Click the "Classify" button near the bottom

This creates several classes based on the values of the POP2000 column. You can change the classification mode (the default is quantiles) or the number of classes.

image

If you have trouble changing the color of the splatters, see the note above about setting fill="param(fill)" in the SVG file.

If we want to change the size, rather than the color, above the list of classes, set:

  • Method = Size
  • Size from = 5.0 to 15.0

image

If you want to control both size and color from different attributes, it's usually easiest to set the color with a graduated style, then use a data-defined override for the size.

If you want to get really fancy, you could even use several different SVG files, and pick a random one by using a data-defined override expression like:

'D:/path_to_project/splatter' || rand(1,3) || '.svg'

This will randomly select the splatter1.svg, splatter2.svg, or splatter3.svg file.

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="1280.000000pt" height="1202.000000pt" viewBox="0 0 1280.000000 1202.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.15, written by Peter Selinger 2001-2017
</metadata>
<g transform="translate(0.000000,1202.000000) scale(0.100000,-0.100000)"
fill="param(fill)" stroke="none">
<path d="M7355 12005 c-248 -54 -425 -237 -495 -510 -57 -219 -24 -641 79
-1044 27 -102 71 -274 99 -381 55 -214 76 -328 92 -495 45 -493 -60 -892 -293
-1112 -177 -167 -398 -234 -708 -212 -288 20 -495 108 -680 289 -192 189 -283
363 -476 919 -47 135 -106 293 -132 351 -147 330 -336 480 -603 480 -109 0
-165 -19 -231 -80 -101 -93 -143 -214 -133 -385 11 -189 70 -348 189 -505 83
-109 176 -198 410 -389 361 -296 456 -434 457 -666 0 -172 -39 -275 -147 -381
-101 -101 -265 -174 -486 -219 -159 -31 -334 -50 -647 -70 -590 -37 -774 -77
-865 -189 -28 -35 -30 -44 -30 -119 0 -101 22 -151 104 -239 72 -78 164 -148
401 -303 243 -159 336 -229 430 -324 88 -89 145 -171 179 -261 24 -60 26 -77
25 -215 -1 -132 -4 -161 -28 -238 -123 -410 -455 -609 -1181 -711 -60 -9 -220
-27 -355 -41 -135 -14 -299 -33 -365 -41 -459 -57 -680 -150 -772 -325 -26
-49 -28 -63 -28 -159 0 -90 3 -111 23 -147 48 -91 126 -144 269 -185 67 -19
102 -23 238 -22 223 0 305 23 744 210 307 132 475 194 621 233 210 55 287 65
505 65 174 0 212 -2 289 -22 254 -64 425 -191 522 -387 60 -124 77 -207 77
-385 -1 -243 -42 -430 -142 -635 -164 -337 -370 -539 -1025 -1006 -502 -357
-735 -590 -875 -874 -104 -211 -146 -407 -138 -645 3 -121 9 -158 31 -227 62
-190 206 -324 408 -379 77 -21 248 -29 350 -15 423 57 714 297 953 786 105
216 162 367 349 935 170 516 262 764 356 950 294 588 660 854 1205 877 233 10
460 -30 633 -112 325 -154 523 -433 642 -900 51 -200 82 -398 130 -835 58
-524 97 -723 172 -875 58 -118 129 -189 226 -226 51 -19 71 -21 187 -16 103 4
146 10 210 30 212 69 353 218 390 413 19 95 19 141 0 228 -22 103 -72 193
-214 385 -71 96 -152 213 -180 259 -142 238 -196 514 -173 879 20 316 64 508
162 708 94 194 211 315 385 400 135 66 227 86 435 92 409 13 924 -49 1264
-152 404 -123 633 -254 1126 -646 360 -286 586 -379 919 -379 87 0 145 5 182
16 179 53 303 186 356 384 25 90 24 309 -1 399 -68 248 -255 411 -596 519
-148 47 -302 78 -745 152 -599 100 -850 164 -1094 281 -269 128 -478 323 -594
554 -202 404 -207 1039 -11 1463 85 185 247 376 430 508 105 76 364 206 519
263 61 22 242 80 403 130 395 123 516 173 631 259 68 51 105 96 139 169 25 53
27 68 26 173 -1 137 -18 211 -77 325 -121 232 -372 356 -692 343 -130 -6 -217
-35 -336 -114 -106 -69 -290 -259 -475 -489 -198 -245 -290 -349 -380 -427
-218 -188 -337 -218 -749 -187 -759 56 -1149 310 -1335 868 -75 223 -110 491
-110 831 0 383 38 546 225 965 179 402 228 613 229 990 1 158 -2 190 -22 263
-46 170 -115 286 -236 399 -155 144 -366 203 -571 158z"/>
<path d="M545 8539 c-99 -13 -238 -54 -309 -92 -118 -62 -203 -173 -226 -296
-33 -173 11 -318 136 -451 103 -109 231 -181 419 -236 141 -41 259 -56 480
-61 312 -7 520 24 690 106 95 46 155 95 193 159 23 40 27 58 27 118 -1 62 -6
82 -37 145 -121 243 -472 483 -853 584 -86 23 -124 27 -275 30 -96 2 -206 -1
-245 -6z"/>
<path d="M10180 1384 c-210 -37 -353 -117 -469 -262 -103 -128 -145 -256 -145
-437 1 -102 5 -132 27 -200 36 -110 89 -196 172 -279 82 -83 168 -136 280
-173 70 -23 96 -27 210 -27 114 0 140 4 210 27 111 37 198 90 280 172 82 82
135 169 172 280 22 68 27 98 27 200 0 85 -5 139 -17 185 -67 244 -259 434
-499 494 -68 17 -204 28 -248 20z"/>
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment