owntracks / talk

Questions, talk about OwnTracks
32 stars 4 forks source link

Visualize Owntracks data with QGIS #177

Closed harlock974 closed 8 months ago

harlock974 commented 8 months ago

I was wondering how to watch my friends location on a map displayed by QGIS.

If you have a Linux computer, it is quite easy actually.

You should have jq and mosquitto-clients installed. To do this use your package manager, or, for Debian-Ubuntu-Mint like distros, type in a terminal :

sudo apt install jq mosquitto-clients

Then type in a terminal :

while true;do mosquitto_sub -W 1 -h host_ip -p host_port -t 'owntracks/#' -u your_username -P your_password | jq -r '.tid+","+(.tst|tostring)+","+(.lon|tostring)+","+(.lat|tostring)' > /tmp/owntracks.txt;sleep 10;done

Replace host_ip, host_port, your_username, your_password by your credentials. You can change the refresh delay in seconds after sleep command.

Then in QGIS, add a delimited text file layer, choose /tmp/owntracks.txt, comma separated, and declare field_3 as X and field_4 as Y, CRS EPSG:4326-WGS 84.

Dot showing your friends should now appear in an owntracks layer. In the layer property, add a tag for field_1, and in rendering, tick to reload the layer every 60 s for example.

jpmens commented 8 months ago

Archived.