2

I am working currently on a small-scale map using among other sources Natural Earth shapefiles (NE).

For an unknown reason, one of the polygons created by me on the basis of the fragments of NE coastline and administrative border can not be selected with Select tool and merged with other features. It can be selected through the Attribute Table but after merging it disappears completely (instead of being added to other territories of Dutch East India [the map depicts the 1905 situation]).

I checked validity of both lines that were used to create the polygon and the polygon itself. The validator does not show any errors, neither there are any error messages in the log windows (as it was the case in Cannot select polygon using QGIS). I suspect something may be wrong with the polygon but I cannot figure out what exactly is wrong. The shapefiles in question are temporarily uploaded to GitHub. I do not use spatial index, the set of shapefiles contains only the following files: .cpg, .dbf, .prj, .qpj, .shp, and .shx

Using QGIS 3.4.2-Madeira under Ubuntu 16.04

  • What data format are you using? This can be a symptom of a corrupt spatial index in the dataset. – ndawson Jan 2 at 23:03
  • The source is Natural Earth dataset provided with QGIS as a tutorial. I guess, it must be error-free? – Alexei Kouprianov Jan 2 at 23:05
  • I mean -- is it a shapefile? Spatialite? Geopackage? – ndawson Jan 2 at 23:10
  • I would say, they are shapefiles, see naturalearthdata.com/downloads/10m-physical-vectors – Alexei Kouprianov Jan 2 at 23:21
  • The project as a whole is stored in QGZ format, separate layers are saved as shapefiles. – Alexei Kouprianov Jan 2 at 23:26
2

After check that the polygon is not closed correctly, you can fix it using the editing options.

  1. Menu bar > Layer > Toggle Editing.

  2. Digitizing Toolbar > Vertex Tool.

  3. Click right on map to open Vertex editor panel.

Steps 1,2 and 3

The first and the last points of a valid polygon must be the same point. If they are different, the ring is not closed and the polygon cannot be built correctly. If you select the first vertex (0) and the last vertex you can see that are not the same point.

Vertex 0 Vertex 0

Vertex 1981 Vertex 1981

You only need to move one of them to the same position than the other and save the changes.

Now you can select correctly the polygon because is closed.

1

Yes, an error is found in the figure if its validation is verified with the QGIS method of the Check Validity tool:

error

I couldn't find where the polygon doesn't close, so I used a GRASS tool (i.e., v.reclass) that includes the v.in.ogr function, which allows assigning a snap value when importing the vector map.

So I tried to reclassify it by assigning the v.in.ogr snap tolerance option to 0.000001 :

v-reclass

The result is a new layer called Reclassified with the valid (multi)polygon.

Note that the generated area also has an island although it is not shown.

Number of nodes: 1
Number of primitives: 2
Number of points: 0
Number of lines: 0
Number of boundaries: 1
Number of centroids: 1
Number of areas: 1
Number of isles: 1
  • For some reason, I can not activate the GRASS tools (even though I can see them inactive). Nonetheless, yours is a most useful comment: as a novice, I did not appreciate the difference in polygon validation algorithms before. – Alexei Kouprianov Jan 3 at 22:32
  • 1
    Note that I am referring to the built in GRASS tools, those you can access from the Processing Toolbox. Not those that are included in the GRASS Tools plugin. To activate the plugin tools you must first create a mapset. I recommend doing it directly from GRASS GIS (installed together with QGIS) to familiarize yourself with the GRASS workflow. When you want to try, I recommend checking this Quickstart documentation. – Gabriel De Luca Jan 4 at 1:36
  • It seems that this toolbox became fully functional only after I installed the stand-alone version of GRASS (and not just some GRASS components installed as parts of QGIS). Now I managed to replicate your recipe. Time to answer the question. – Alexei Kouprianov Jan 5 at 11:48

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.