I have a .shp file of the world oceans (hydropolys.shp) and create a map with it in QGIS, so the background of the image is the land. Does anyone have any suggestions on how I can overlay my raster output on top of the oceans, but not overlain on the land? So I essentially want my image overlain on top of the uploaded .shp file but underneath the background.

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Feb 28 '19 at 19:43

You can't put the map canvas background in front of a map layers. What you can do, is create a land layer and put it in front of the raster image.

Since you already have oceans, you don't even need new data.

  1. Duplicate the ocean layer: right click on the layer name 'hydropolys', choose "duplicate layer" from the menu.

    enter image description here

    Now you have a new layer called 'hydropolys copy'.

  2. Style 'hydropolys copy' with an inverted polygon fill. This will shade in all of the area outside the oceans, IE the land. Match the fill color to the color of your map canvas background.

    enter image description here

  3. Arrange the layers in the Layers panel in this order:

    enter image description here

| improve this answer | |
  • Thanks! Are there matching commands for writing this in PyQGIS so I can skip this process and create the land layer directly in PyQGIS? – user137875 Feb 28 '19 at 20:01
  • There probably are matching commands in pyqgis, but I don't know them. I hear there's a pyqgis manual, though. That seems like the place to go if you want to learn how to code in pyqgis. – csk Feb 28 '19 at 20:13
  • Can I export the new hydropolys copy into a shp file? – user137875 Feb 28 '19 at 20:24
  • There's no need to create a new layer, because it's the same data with a different style. If you export 'hydropolys copy' you're just creating a copy of the 'hydropolys' shapefile. – csk Feb 28 '19 at 20:27
  • I have another question sorry. I want to export the inverted polygon layer so the shapefile has the land as the vector layer to use in Pyqgis. Can I do this or will it just export the same shape file? – user137875 Mar 4 '19 at 21:09

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.