Skip to content

Instantly share code, notes, and snippets.

@HeikkiVesanto
Last active November 26, 2021 17:57
Show Gist options
  • Save HeikkiVesanto/252b7d65ba839de8a6f83065c7f27505 to your computer and use it in GitHub Desktop.
Save HeikkiVesanto/252b7d65ba839de8a6f83065c7f27505 to your computer and use it in GitHub Desktop.
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