I am attempting to map arctic regions. I have a predetermined area off the coast of Alaska that has longitudes both negative and positive. In a north pole azimuthal equidistant projection, it looks as it should, pictured in the first image. However, when I use the difference tool in order to remove land masses from the polygon, it uses the WGS 84 projection which crosses the map, missing all of the land that is actually within the region defined as shown below. Can I make the difference tool use a different projection? Does the reprojection tool solve this using some specifications beyond the most basic target CRS? Can I redefine my polygon to cover the proper landmass even on the WGS 84 projection?
2 Answers
Use either Geometry generator (for visualization only) or Geometry by expression (to create actual geomtries) with the expression from below - see here for details about both options. Be aware: 3995
is the EPSG-code for the Arctic Polar Stereographic projection, 4326
for WGS84 CRS - change this if you use another CRS.
You might also use the variable @layer_crs
instead of 4326
if your layers are not in EPSG:4326
.
Explanation: the expression reprojects both layers from their layer CRS (here: both layers are in EPSG:4326
) internally to EPSG:3995
, then makes the geoprocessing (difference
) and then projects the result back in EPSG:4326
(respectively the CRS your layer is saved in).
transform (
difference (
transform (
aggregate(
'World Map', -- change the layer name if necessary
'collect',
$geometry
),
'EPSG:4326',
'EPSG:3995'
),
transform (
$geometry,
'EPSG:4326',
'EPSG:3995'
)
),
'EPSG:3995',
'EPSG:4326'
)
Blue polygon (hached) created with the expression above, based on
the layer 'World Map'
that contains the Earth's land mass. Both layers here are in EPSG:4326
:
-
It seems that when I insert the script, altering the CRS values as well as the Layer name, I don't get any results and see no difference. I'm assuming user error. I am looking to get a shapefile of the polygon in yellow without the landmasses. I don't understand how this solution fixes this issue as it doesn't seem to create a new shapefile and I really can't see the desired goal of a hole in the polygon in the image you provided. If I'm missing something, could you please elaborate? Commented Jun 22, 2022 at 21:45
I was able to manipulate QGIS to process the yellow region as all negative longitudes, solving my issue by subtracting 360 degrees from the positive longitudes, resulting in this polygon:
-
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.– Community BotCommented Jun 22, 2022 at 22:06