8

I would like to know if there is any way of mirroring layers on QGIS. My current project is a bit hard to explain... I'm excavating the inside of a large pot and, in the end I will have a set of plans that correspond to the successive layers I'm exposing as I go along with the excavation. However, for pratical reasons, I Have to do this work upside-down (i.e., the excavation started from the bottom of the pot).

All my records will later be edited in QGIS so, in order to make more understandable for other people, I will need to reverse them. Not just reversing their order, but also flip them horizontally, getting a mirrored image of each layer's plan.

I know I could do it with image processing software, but I was wondering if there is any way of doing it within the QGIS environment - this would probably save me image processing time and make it a more streamlined workflow.

Does anyone has any ideas on this?

1
  • Your plans are images? And you have one image per every stage? Just use any drawing software like basic Paint in Windows to flip them (horizontally or vertically). If you have a lot of plans, something what can do that in batch - like opensource GIMP or free IrfanView. Order of plans depends only how you order images (layers) in QGIS - that is totally up to you.
    – Miro
    Jul 16, 2015 at 2:01

2 Answers 2

10

Yes, you can mirror layers (or individual features). This requires QGIS >= 2.10. It's not necessary to actually modify the input data, just the way it is presented. This is done using layer effects as shown here for Alaska:

enter image description here

5
  • Many thanks for your answer, but I'm not being able to find where to access that "Effect Properties" window. I understand from the image you've shared that it is inside the Style tab of Layer properties, but I can't seem to figure out where is it. I'm currently running QGIS 2.8.2.
    – TTome
    Jul 26, 2015 at 17:34
  • 1
    You need 2.10 to be able to use effects.
    – underdark
    Jul 26, 2015 at 17:39
  • After posting my comment, I wondered if that would be the case, uninstalled 2.8.2, installed 2.10 and voilá! Thanks for your help!
    – TTome
    Jul 26, 2015 at 18:13
  • 2
    And how can you do that in QGIS > 3.0?
    – sk1me
    Oct 4, 2019 at 10:23
  • 1
    In QGIS > 3.0 it's similar: under Layer Properties/Symbology you mark "Simple fill" of your vector, then click "Draw effects" and a star button (both are positioned below) - you get "Effects properties" window, and under effect type select "Transform" and mark "reflect vertical". Jul 1, 2020 at 10:50
10

As you state, you could do this in image processing software, but if you want to do it in QGIS for a smooth workflow (perhaps using a script or creating a processing Model), you can flip your images using the Grass function r.flip. However, this is in Grass 7 so you would need to install that as it is not yet standard in QGIS.

Also, there is SAGA's Grid Orientation tool, which offers flip, mirror and invert options. The documentation seems sparse for this but a quick experiment shows that 'flip' flips the image vertically, 'mirror' flips the image horizontally, but invert makes a 'negative' of the image (so not what you want, I suspect - but flip and mirror look promising for your use).

EDIT (re comments): To mirror, rotate or otherwise 'rubber-sheet' vector data you need affine tools. QGIS has a number of tools for this. There are a couple of plugins ('Affine' and 'Vector Bender') and Grass has v.transform. You need to compute your transformation matrix for Affine or v.transform. See this post for the former. Alternatively, if you are very familiar with rubber-sheeting rasters (and too lazy to work out transformation matricies), then use the Vector Bender plugin - though I think it would be harder to work out your mirror lines for this particular use-case (otherwise it is brilliant).

Using Affine plugin and a transformation matrix of
1,0,0
0,-1,0

I get the following (blue = before, yellow = after): enter image description here

The matrix here is actually flipping about the Y-axis, so you'd need a lateral transformation as well equal to the north-south extent of your data to flip 'in place'. So, in my case my real matrix based on this particular shapefile, would be
1,0,0
0,-1,964530.15

(i.e. I am fliping down on the Y-axis and then shifting the data back up)

EDIT #2 (An Afterthought):
If you are performing a batch process, you can get the extent through GDAL easily enough and automate the creation of the transformation matrix. However, if you are doing a semi-manual process, in your use-case you can simplify things by unioning a simple bounding-box polygon with each layer's data. That way your transformation matrix will always be the same as the total extent of your data will always be within your bounding box regardless of what you actually digitize in the layer.

3
  • MappaGnosis, yours is quite an interesting sugestion (Grid Orientation Module) - however, it only works with raster data, I was looking for something that could be used with vector data as well. Regarding scripts and processing models, I'm not that well versed in the art of scripting as to do it that way...
    – TTome
    Jul 16, 2015 at 16:06
  • I only mentioned rasters because you refered to images in your question. However, if you want to flip vectors too, it is also possible by affine tools. See my edits above. Jul 17, 2015 at 7:59
  • Sure, I understand - it was me who wasn't clear enough with what I need to do. Your new adtitions to your comment seem great. I will only be able to test it out in a few days, because I don't have access to the data right now, but will surely give it a try - will let you know how it went afterwards. Many thanks!
    – TTome
    Jul 18, 2015 at 13:54

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.