Last active
February 12, 2018 18:19
-
-
Save NathanW2/1933f13bebe548db1104 to your computer and use it in GitHub Desktop.
Web images as QGIS markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import base64 | |
@qgsfunction(args='auto', group='Custom') | |
def show_camera(feed, feature, parent): | |
svg = """ | |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<svg> | |
<g> | |
<image xlink:href="data:image/jpeg;base64,{0}" height="256" width="320" /> | |
</g> | |
</svg> | |
""" | |
data = requests.get(feed, stream=True).content | |
name = feed[-16:] | |
b64response = base64.b64encode(data) | |
newsvg = svg.format(b64response).replace('\n','') | |
path = r"C:\temp\camera\{0}.svg".format(name) | |
with open(path, 'w') as f: | |
f.write(newsvg) | |
return path.replace("\\", "/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is were I did arrive
import requests
import base64
@qgsfunction(args='auto', group='Custom')
def show_image(pSourceFile, pFileName, feature, parent):
svg =
.
.
.
fullorigpath = "D:\MDKD\MOZA\60 INFRA\09 software\2018-02 GPSfotolapse_1_5_6\v01\vdf200"
fullorigpath = fullorigpath.replace("\", "/")
pSourceFile = fullorigpath + pSourceFile[1:]
and this the error I get
'ascii' codec can't decode byte 0x81 in position 30: ordinal not in range(128)