Geographic Information Systems Asked on March 22, 2021
When I embed an SVG symbol in QGIS 3.x, the symbol is stored in the layer definition. If I have another layer and like to use the symbol again, I have to embed it a second time.
How can I embed an SVG symbol globally and use it in multiple layers?
While playing around with Data URIs, I managed to store SVG images inline without base64 encoding. Only have to put 'data:image/svg+xml;utf8,' in front. Depending on the SVG content, the inline SVG data strings are much smaller without encoding.
'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px"><path fill="param(fill) #000000" d="M50,2.5c-19.2,0-34.8,15-34.8,33.4C15.2,61.3,50,97.5,50,97.5s34.8-36.2,34.8-61.6 C84.8,17.5,69.2,2.5,50,2.5z M50,48.2c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9c7.1,0,12.9,5.8,12.9,12.9 C62.9,42.4,57.1,48.2,50,48.2z"/></svg>'
Correct answer by christoph on March 22, 2021
Found the answer to my problem: We can store the base64 encoded SVG string in a project variable and link to this variable (i.e. 'mySymbol').
base64:PHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1NzkuOTk3IDU3OS45OTciIGhlaWdodD0iNTc5Ljk5NyIgdmlld0JveD0iMCAwIDU3OS45OTcgNTc5Ljk5NyIgd2lkdGg9IjU3OS45OTciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Im0yODkuOTk3IDMzLjMxbC0yMjQuNjEgNTEzLjc2NSAyMjAuNDk5LTE0My45NDYgMjI4LjYzMiAxNDMuNzM2eiIgZmlsbD0icGFyYW0oZmlsbCkiIGZpbGwtb3BhY2l0eT0icGFyYW0oZmlsbC1vcGFjaXR5KSIgc3Ryb2tlPSJwYXJhbShvdXRsaW5lKSIgc3Ryb2tlLW9wYWNpdHk9InBhcmFtKG91dGxpbmUtb3BhY2l0eSkiIHN0cm9rZS13aWR0aD0icGFyYW0ob3V0bGluZS13aWR0aCkiLz4KPC9zdmc+Cg==
Answered by christoph on March 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP