6

I am looking for a very simple thing. I want to create a polygon based on the current view extent of my project.

In fact I want to:

  1. open google satellite layers
  2. zoom to my area of interest
  3. create a polygon based on the 'view extent'

of course, the GE layer is not important, it should work with any view.view

4 Answers 4

8

Sounds like spatial bookmarks - maybe that's also an option.

But given that you have a current polygon layer in the same CRS as the project, you can do this in the python console to add a new feature with the current extent:

f = QgsFeature()
f.setGeometry(QgsGeometry.fromRect(qgis.utils.iface.mapCanvas().extent()))
l = qgis.utils.iface.activeLayer()
l.startEditing()
l.addFeature(f)
l.commitChanges()
0
3

I have found the optimal answer (sorry @Jef, I started digging into the Python console, and will continue, but this one was quicker).

The QMarxan plugin allows for creating a grid from the view extent.

1
  • 1
    Mind that: This plugin is deprecated!
    – Taras
    Nov 17, 2021 at 6:43
2

QGIS 3.10 introduced 2 new tools (or maybe in earlier versions). With it, you can convert layer features to bookmarks or vice versa:

Convert layer to spatial bookmarks

Convert spatial bookmarks to layer

1

I had this need in QGIS 3x and the following workflow allowed me to quickly create the polygons.

In the map layout I got the map to the scale and extent required and checked the extent values in item properties for the frame. enter image description here

I put these into a Google Sheet - https://docs.google.com/spreadsheets/d/1DIkh3neqY_aF0jLjv8myjzG16ncx92DyobBSH22scdU/edit?usp=sharing

I then imported them into QGIS as Polygon WKT enter image description here

This gave me the polygons I needed for an atlas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.