[GIS] Extract the polygon layer vertices and delete the unwanted ones in QGIS

qgisvertices

I need to extract the vertices coordinates of the four corners of each rectangle of a layer made up of 729 polygons (= map sheets). I began using Vector/Geometry Tools/Extract Vertices function to create a vertices layer but each rectangle contains 7 vertices – the first and the last are superimposed, I suppose – so I want to eliminate the median vertices and one of the two (the first or the last) vertices superimposed. Moreover the 4 vertices of each rectangle coincide with the vertices of the adjacent rectangles having the same coordinates but different attributes related to the different map sheets.
enter image description here

Now I do not know how to delete the unwanted vertices (I can not use the Processing / Vector General / Delete Duplicate Geometries function because it would also delete the vertices of adjacent rectangles).
How to solve this problem?

Best Answer

As your polygons are essentially square then running Processing -> Simplify on them using default tolerance (1.00) should be enough to remove the extraneous vertices and leave you only with corners (4 per polygon).

You can then use Processing -> Extract Vertices to create a point file of all vertices (albeit I don't know if this extracts the underlying polygon attributes). You can add geometry information using Processing -> Add Geometry Outputs.

EDIT

The original answer above works on small-scale cartographic coordinate systems such as British National Grid because generated grids are actually square/simple and therefore can be represented by only 4 vertices. In this case the data is in UTM 32N and closer inspection of the data reveals that the polygons are not regular due to the distortion from the projection. This appears to be the reason that standard methods such as simplification don't work. Because there is no standard pattern to vertex order, ramping up simplification tolerances ends up destroying a lot of the polygons rather than extracting corners.

The method outlined below does appear to work for the purposes laid out in the original question. It could be relatively easily automated as it isn't the most elegant:

  1. Add a unique identifier to your polygon layer if they don't already have one
  2. From Processing -> SAGA -> Vector General run the Feature Extents tool, using Each Shape as the creation option. This creates a new polygon layer which is essentially identical to the original but intervening nodes are trimmed out. Because of this there is a small degree of offset between the corners of each polygon (see image). Some spot testing suggests this is <50m.

Step 2 result showing polygon corner offset

  1. If you add a new field to the attribute table of these new polygons and run num_points($geometry) you'll see that for some reason each polygon still has 5 vertices. Two of these per shape are identical, although where they occur and their index value is not standard. Testing indicates that Remove duplicate vertices doesn't seem to work regardless of tolerances; this may be a geometry error. Instead, to remove the duplicates run Processing -> Vector General -> Vector Geometry -> Extract Vertices to get the vertices of these new polygons.
  2. Finally run Processing Processing -> Vector General -> Remove Duplicate Geometries to delete the duplicates.

You should be left with a point file where each group of four points represents the corners of a polygon grid square. There will be slight offset between the corners of each polygon but given the scale of your map you should be able to round this out when displaying the values (as per your original question linked in the comments). You will be able to identify each group of four using the unique ID you added in step 1.