Skip to content

Instantly share code, notes, and snippets.

@jarnaldich
Created January 30, 2020 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarnaldich/151b8b2d33fec7bd22477dad8bbbd8ad to your computer and use it in GitHub Desktop.
Save jarnaldich/151b8b2d33fec7bd22477dad8bbbd8ad to your computer and use it in GitHub Desktop.
Copying map extent to clipboard in QGIS with python #qgis #python
def copy_extent_to_clipboard(separator=';'):
ext = iface.mapCanvas().extent()
coords = [ ext.xMinimum(), ext.yMinimum(), ext.xMaximum(), ext.yMaximum() ]
txt = separator.join([ "{:10.4f}".format(x) for x in coords ])
QgsApplication.clipboard().setText(txt)
# Run: exec(open('C:/Users/j.arnaldich/copy_extent_to_clipboard.py'.encode('utf-8')).read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment