3

I have the following situation: I have a MultiPolygon Layer that shows some squares with the size of 100mx100m. The data looks like a raster:

Layer with MultiPolygons

I want to construct a grid with the size of 100mx100m (rectangle(polygon)), so that it fits over the MultiPolygons. I have tried it with the grid-tool in QGIS. In the settings for the expansion parameter I have tried all options, but I always get a result like in the following picture:

grid and MultiPolygon Layers

Does anyone have an idea how to fix the grid over the squares so that the grid fits perfectly over them?

3
  • 3
    You have tried different origins for the grid? Does your polygons have the same spacing?
    – BERA
    May 5, 2021 at 7:29
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    May 5, 2021 at 7:31
  • I have tried different origins with the expansion parameter. First I have tried it with the expansion from the MultiPolygons and after that with the expansions from the boundary layer. The Polygons have all the same size and they can be anywhere in the boundarys.
    – divko
    May 5, 2021 at 7:34

2 Answers 2

5
  1. You know the spacing is 100m in both x and y.
  2. "Create grid" via Vector > Research Tools > Create Grid
  3. Grid Type - set it to Rectangle
  4. Grid Extent
    1. set it to Calculate from Layer and select the polygon layer - it will fill in the numbers. The first 2 are the east-west range of the polygon layer, the last 2 are for north-south. The CRS of the layer is also shown.
    2. modify the coordinates by a multiple of 100m if some kind of overlap is required. This will place the origin of the grid so that grid cells are aligned with your existing polygons
  5. Set Horizontal Spacing & Vertical Spacing to 100m.
  6. Set the Grid CRS to be the same as the layer you are aligning to.
  7. Press Run

Input

enter image description here

Parameters

enter image description here

Output

enter image description here The extent looks long in the south because I have some transparent cells. It is correctly aligned.

1

Easiest way probably is snapping the grid to the polygon layer with the squares:

  1. Activate snapping (choose snap to vertices and all layers).

  2. Select all features of the grid (like Ctrl+A in Windows).

  3. Toggle editing for the grid layer.

  4. Select Move feature, click on one of the corners of the grid and move it over one of the corners of the green rectangles so that it snaps to it and you're done.

enter image description here

Result:

enter image description here

2
  • 1
    Brilliant. 10 years, and I have never snapped! At first, I kept getting edges. then I selected the Vertex option in the toolbar menu Snapping Options
    – wingnut
    May 5, 2021 at 13:31
  • So start snapping now ;-)
    – Babel
    May 5, 2021 at 19:38

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.