Skip to content

Instantly share code, notes, and snippets.

@timlinux
Created April 16, 2013 16:41
Show Gist options
  • Save timlinux/5397459 to your computer and use it in GitHub Desktop.
Save timlinux/5397459 to your computer and use it in GitHub Desktop.
iface = qgis.utils.iface
# make sure the raster layer is active before you type the next commands
l = iface.activeLayer()
r = l.extent()
s = r.toString()
t = s.split(' : ')
t1 = t[0].split(',')
t2 = t[1].split(',')
wkt = 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (t1[0], t1[1], t1[0], t2[1], t2[0], t2[1], t2[0], t1[1], t1[0], t1[1])
print wkt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment