Skip to content

Instantly share code, notes, and snippets.

@HeikkiVesanto
Last active Nov 26, 2021
Embed
What would you like to do?
Spinning globe
# QGIS spinning globe export.
# Run https://gist.github.com/Joonalai/7b8693ef904df75cb15cb9af0e82c032 first
# Uses the GISPO globe plugin: https://github.com/GispoCoding/GlobeBuilder/
import time
from PyQt5.QtGui import *
mapCanvas = iface.mapCanvas()
vLayer = iface.activeLayer()
def spin(seconds):
"""Pause for set amount of seconds, replaces time.sleep so program doesn't stall"""
time_end = time.time() + seconds
while time.time() < time_end:
QApplication.processEvents()
c = 100
load_globe_view(0,0)
change_globe_origo(0, 180)
# after running the above line, you should do a zoom to layer, and copy the resulting scale to the below line and into the loop.
mapCanvas.zoomScale(63443132)
# I copy this in seperately:
for i in range(180, -180, -10):
c += 1
print(i)
change_globe_origo(0, i)
mapCanvas.zoomScale(63443132)
spin(10)
mapCanvas.saveAsImage('C:/path/path/globe/' + str(c) + '.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment