3

Using QGIS 3 I'm having difficulty with what seems to be a simple problem: for each US state and Canadian province with a coastline (on Shapefile maps I downloaded), replace the coastline segments with a minimum number of segments that will encompass any belonging islands.

Essentially, I want to delete all the coastline vertices except one on each end of the coastline, then extend the coastline by drawing a few line segments out into the ocean (or lake) that will surround the belonging islands, and delete the island vertices from the feature.

I have found very laborious and error-prone ways to do it, but nothing efficient. Ideally, I'd like to select two points on a coastline and delete all the points in between with a command. Selecting the in-between points is clumsy the way I do it, using the vertex tool, trying to "box" parts of the coastline and delete in pieces, zooming in and out, etc. Is there a simple way to do this?

Once I have replaced the coastline with a single line segment, I'd like to stretch it out around the islands as a couple of additional segments. I visualize this as dropping a couple of points into the coastline segment, then dragging those points outward. Alaska has a bundle of islands. It would be great to extend the coastline around the islands, then with some command deletes all the separate polygons (islands ) contained inside the big polygon. In any case, there are probably a number of ways to get the end result.

2
  • 5
    A lot of text. Can you add a screenshot or drawing of before and after?
    – BERA
    Mar 25, 2021 at 6:27
  • 2
    As mentioned by @Bera, adding a screenshot would help. What you want to achieve is not clear to me. Consider this part of the coast of Alaska: the black line is selecting a start- and end-point on the coast and deleting all verticen in between. The red line is a line including all islands. However, both lines cross. What to do in such cases? See: i.stack.imgur.com/Vik0n.png
    – Babel
    Mar 26, 2021 at 15:08

3 Answers 3

1

I believe I have a workable solution, although I'm clumsy with it.

OS: Windows 10

QGIS3 3.18.1-Zürich

  1. Select the feature (left-click the "select features" tool, then left-click the feature on your map). (depending on your map, it could be one or perhaps several polygons). Or you can open the Attributes Table (left-click the "Open Attributes Table" icon) and find the feature in the list and click its row number to highlight it. The "zoom to feature" icon in the tool is useful for finding the feature on your map).

  2. Enter edit mode (click the pencil).

  3. Select the Vertex tool (left-click the tool icon, or select "current layer" from it's dropdown menu).

  4. Right-click your selected feature on the map. This should open the "Vertex Table" in a pane.

  5. Hover your mouse over the feature on the map, the vertices should be highlighted.

5b. Shift-left-click the vertex at one end of the stretch of vertices you want to select. Shift-left-click the vertex at the other end of the stretch.

  1. Now scroll through your vertex table. Two vertex rows should be highlighted. Now the trick is to highlight the vertices between them. The most reliable (clumsy) way I found is to go to the first highlighted vertex row and Ctrl-left-click the vertex row below it. Then go to the last highlighted vertex row and Shift-left-click the vertex row above. If you want, you can then Ctrl-left-click any vertex row you feel like excluding (like the end points).

  2. When you have the stretch of vertices you want highlighted, you can hit the Del key to delete them or do whatever processing you can do on selected vertices.

There are probably slicker ways or shortcuts to do this.

1

This solution is based on a convex hull as that seems to be what you're looking for. See the following screenshot for the coastline of California. The result here is a polygon (with no fill, just a black stroke line for the boundary). You can easily convert the polygon to a line and delete the segments on the inland, see below for that. enter image description here

How to do it:

  1. Convert the polygons of the states to its boundary line: Menu Vector / Geometry Tools / Polygons to lines (alternative: create new line geometries with expressions using this expression: boundary ($geometry))

  2. Create individual features for each segment of the line from step one: Menu Processing / Toolbox / explode lines. Be aware: saving this layer as Geopackage might fail because of unique identifier violation: the fid field contains the same value for different features. Simply delete the fid field, than saving should work: QGIS creates a new fid-field. See here for more details.

  3. Select only those segment that form the coast (be it mainland or island). This is best done using a basemap polygon layer, like the pre-installed world basemap (type world to the coordinates field at the bottom of your QGIS window) - the geometries should be fitting, however: if coastline and land-area overlap in the two layers, it could be a problem. So best use the same dataset. Delete (use a copy of your data!) the feature containing the area of your interest, thus in my case California. Than use Menu Vector / Research Tools / Select by location, set the exploded boundary from step 2 as Select features from, check the box disjoint and for By comparing to the features from set your basemap. Now, all coasline segments are selected. You can either deleted the others or create a new field using field calculator to define an attribute coastline = 'yes'.

  4. Now merge all the selected segments, thus all coastline segments, be it mainland or island coastline. Use the icon Merge Selected Features from the Advanced Digitizing Toolbar. This may take a while, depending on the complexity of your shapes. Be aware: merging might fail if your layer is singlepart - create a new multipart (Multiline) layer and copy/paste the lines there.

  5. Now use Menu Processing / Toolbox / Convex hull and apply it to the merged coastlines created in step 4. The result is the polygon shape you see in the scrrenshot above.

  6. If you only want to keep the line in the sea, first convert your polygon to a line: Menu Vector / Geometry Tools / Polygons to lines - than explode the line again (see step 2). Now use Select by location (compare step 3), select all segments that cross the landmass: check are within and set the original polygon of your area of interest for By comparing to the features from. Than delete the selection. You remain with the line you're looking for.

enter image description here

2
  • Thanks for pointing me to these new techniques - I will have to step through to better understand. I had wondered what "convex hull" did. I've been experimenting with "merge" with polygons -- it seems two polygons must share exactly some set of points, though perhaps there is a "snap" type of parameter somewhere to merge polygons near each other. I have not tried merging "line" features.
    – sb4
    Apr 3, 2021 at 19:36
  • See here for convex hull, especially the rubber band analogy: en.wikipedia.org/wiki/Convex_hull
    – Babel
    Apr 3, 2021 at 19:39
0

Assuming your states/provinces are represented by polygons and not line, draw a polygon like Babel shows, then union that with the polygon for the state.

2
  • Does "union" mean "merge" (I also see a lot of "dissolve" tools that maybe do a merge)? I guess one way to do that would be to "cut" the state polygon, creating an island of the coast which can later be deleted. Then draw a simple polygon surrounding the "coast island", making sure one side matches the cut side of the mainland. Then do a merge, and delete the "coast island".
    – sb4
    Apr 3, 2021 at 19:39
  • Dissolve it what I meant.
    – Llaves
    Apr 4, 2021 at 22:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.