1

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
    Dec 5 '19 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
    Dec 6 '19 at 4:22
  • That's what I thought, and I based my answers on that assumption. Thanks for clarifying.
    – csk
    Dec 6 '19 at 16:28
4

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 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
    May 13 '21 at 3:25
  • Impossible to tell without more details. I suggest you post a question, and include screenshots.
    – csk
    May 13 '21 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

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, privacy policy and cookie policy

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