Skip to content

Instantly share code, notes, and snippets.

@darrenwiens
Created October 4, 2024 18:03
Show Gist options
  • Save darrenwiens/c5db338c63b1e59e095aa0d2bca66303 to your computer and use it in GitHub Desktop.
Save darrenwiens/c5db338c63b1e59e095aa0d2bca66303 to your computer and use it in GitHub Desktop.
Rotate a globe in QGIS by updating the crs
from PyQt5.QtCore import QTimer
from qgis.core import QgsCoordinateReferenceSystem
from qgis.utils import iface
current_index = 0
def update_crs():
global current_index
custom_proj = f"+proj=ortho +lat_0=0 +lon_0={current_index} +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs +type=crs"
custom_crs = QgsCoordinateReferenceSystem()
custom_crs.createFromProj(custom_proj)
iface.mapCanvas().setDestinationCrs(custom_crs)
iface.mapCanvas().refresh()
current_index = (current_index + 10) % 360
timer = QTimer()
timer.timeout.connect(update_crs)
timer.start(500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment