3

I have a vector layer with grid tiles of 100x100 meters that contain data for each tile. I now would like to aggregate those tiles to a lower resolution (e.g. 200x200m, 1000x1000m), preferably in QGIS but also spatial SQL possible.

Can you help find a solution to my problem?

Here's how my layer kind of looks like:

vector grid tiles

I did manage to get a bigger grid now using the create grid feature in QGIS but its not aligned with my initial grid. Looks like its an issue of different projections, but they should be the same in fact: enter image description here

0

1 Answer 1

1

A way you can accomplish this task is through some translates, grid creation, spatial joins and dissolving using QGIS alone.

I tested this on a layer with ~40000 features with a slight rotation, but performance will suffer as you do bigger and bigger areas.

First, using the Translate tool from the your grid system by half its width. In this case, translate your grid 50 metres in the X and Y directions.

enter image description here

Then in the Processing Toolbox use the 'Create grid' tool to create a point grid using the extent of your grid layer, and with an X&Y distance equal to your squared value, in this case 200 metres.

enter image description here

Then using the 'Advance Digitizing Toolbar' select all the points, move and rotate them to fit your grid system. Enable snapping to get accurate placement, though it isn't strictly needed here. On the rotate, you can move the rotate origin with a CTRL-LeftClick so you can more intuitively rotate the grid.

enter image description here

Perform a translate on the point grid, offsetting 50 metres in both X & -Y.

enter image description here

Now preform a 'Join attributes by location', joining your offset polygon grid to the offset point grid. Select 'Discard records which could not be joined', you shouldn't need to set any other parameters.

enter image description here

Perform another 'Join attributes by location' between your original and offset grid. In the 'Fields to add' dialog, select a field that is a unique ID of your offset polygon grid to act as a foreign key. Now tiles from your original grid will share a unique value inherited from the overlaying polygon grid.

enter image description here

Finally, from the Processing Toolbox, do a 'Dissolve' on your joined, original grid using the unique ID as the dissolve field.

enter image description here

Now you have a grid of 200x200 metres. You can just change the values of the spacing and X&Y operators to change the size of grid you want to obtain.

2
  • Wow, thank you for the reply. Don't you think I could use "create grid" tool with my desired dimension (e.g. 200m x 200m), then rotate that grid to fit on my initial layer and spatial join the features?
    – Buglkrax
    Commented Feb 9, 2022 at 8:13
  • Possibly, I was not sure how regular your grid was or if you could accept tiles that didn't touch your original layer; so I was trying a way that would use you existing grid system. And there is probably better solutions from more clever people but that is one I could think of off-hand.
    – RomaH
    Commented Feb 9, 2022 at 14:11

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.