My study area is in black, and in grey the shape of Portugal.
I am creating my study area. It corresponds to the coastal area of Portugal. I have a shapefile for Portugal. I want to crop a raster that corresponds to my study area ( a rectangle), with the shape of Portugal, but what I need is the ocean, so the part that is outside of the mask, the complementary part.
How can I do that?
Best Answer
(1) First, create a rectangle which encompasses your raster.
(1a) Start Extract layer extent tool (in
Layer tools
group).(1b) Select your raster as the Input Layer. Run the tool.
(2) You will get a
Extent
layer.(2a) Now start Difference tool (in
Vector overlay
group).(2b) Select newly created
Extent
as the Inpur Layer. Also select your coastal polygon layer as the Overlay Layer. Then run the tool.(3) You would see
Difference
layer (i.e. your ocean area).(3a) Start Clip raster by mask layer tool (in GDAL > Raster extraction).
(3b) Select your raster as the Input Layer, and Difference polygon as the Mask Layer. Click on the checkbox for
Create an output alpha band
. Run the tool.(4) Hope your final output is something like below.