4

I need a layer with a rectangle that maps it's top left and bottom right corners to north/south and east/west coordinates. This is an Area of Interest which I need to overlay another image layer to see if the things I'm looking for are in the AOI.

How do I do this in QGIS?

It seems hard to find a decent tutorial.

3
  • Your question is tagged with qgis-plugins - are you writing a plugin?
    – csk
    Commented Dec 5, 2019 at 19:40
  • No. The tag description is "Software plugins that add functionality to the QGIS package" (vs Development of Software plugins that add functionality to the QGIS package) and so I tagged the question in case there was a plugin that was relevant.
    – Peter
    Commented Dec 6, 2019 at 4:22
  • That's what I thought, and I based my answers on that assumption. Thanks for clarifying.
    – csk
    Commented Dec 6, 2019 at 16:28

3 Answers 3

9

Because QGIS has more than one way to accomplish a goal, here's another answer.

First, create a new layer in the CRS of your point coordinates. (If the point coordinates are in latitude and longitude, the CRS is EPSG:4326.) It doesn't matter what its geometry type is. Add four fields to the attribute table: xmin, xmax, ymin and ymax. Choose decimal number as the field type. Add a new feature, enter the xmin, xmax, ymin and ymax values from your corner points. Your top-left point is (xmin,ymax). Your bottom-right corner point is (xmax,ymin).

Use the Geometry by Expression tool (from the processing toolbox)

  • Choose Input Layer: any layer that has the same CRS as the point coordinates.

  • Choose Output geometry type: Polygon

  • Use this for the Geometry expression:

      make_polygon( make_line( make_point( xmin,ymin), make_point( xmin,ymax), make_point( xmax,ymax), make_point( xmax,ymin), make_point( xmin,ymin)))
    

Obviously this method is more complicated than my other suggestion. It doesn't make sense to do it this way for only one rectangle. But if you have a lot of rectangles to create, this method will be more efficient than running create grid multiple times. Simply add as many features to the layer as you want to create rectangles.

2
  • this (mostly) works for me...layer is created, attribute table is populated, but the polygons don't draw. What am I missing?
    – CreekGeek
    Commented May 13, 2021 at 3:25
  • Impossible to tell without more details. I suggest you post a question, and include screenshots.
    – csk
    Commented May 13, 2021 at 5:26
2

Here is a manual way of doing it. It is not the fastest but it is straightforward.

Create a new polygon with 4 points (it could be roughly over the area of interest or not, it's not important at this stage).

Enable the vertex editing tool for this layer, right click on the 1st vertex of the layer

enter image description here

Edit the coordinates of the four points to get your desired polygon (the last one is automatically updated to the same value as the 1st one)

enter image description here

1
  • Some additional information for beginners: First, create a Shapefile layer ("Layer - New Layer", use geometry type "Polygon" and set a file name and the CRS), then right-click it in the list to "Toggle Editing" (or press the yellow pencil icon in the image) and "Add Polygon Feature" (icon with the green shape). The "Vertex Tool" is the button next to the green polygon one. The Vertex Editor appears at the bottom left of the window, below the layer list. This youtube tutorial also shows how to create and edit the polygon.
    – Neph
    Commented Oct 30 at 13:43
1

Use the tool Create Grid from the Processing Toolbox.

  • Choose Grid Type: Rectangle (Polygon)
  • Set the Grid Extent using the corner coordinates.
  • Make the Horizontal Spacing the same as the width of your rectangle (calculate as xmax -xmin).
  • Make the Vertical Spacing the same as the height of your rectangle (calculate as ymax - ymin)

For example, these settings make a rectangle 5 degrees wide and 2 degrees long, with its top left corner at lat/long (0,2) and its bottom right corner at lat/long (5,0).

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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