How to display vertex markers in QGIS for non-editable layers?
No need to create a new layer. You can show your layer's vertices using the Outline: Marker line Symbol layer type.
Just add a new symbol layer
- Add a new symbol layer;
- Choose Outline Marker line (top right corner);
- In the Marker placement, Choose "On every vertex"
You can even style the marker to look like the red cross symbol used on layers in edit mode.
Do you have your own schema in which you can make a view that refers to your source table? If so, you can create the following view:
CREATE OR REPLACE VIEW polygon_vertices AS
SELECT row_number() OVER (ORDER BY (st_dumppoints(polygon.shape)).geom) AS objectid,
polygon.field1, -- fields you want to keep in the vertices
polygon.field2, -- that are in the polygon table
(st_dumppoints(polygon.shape)).geom::geometry(Point,4326) AS shape
FROM polygon;
This database view pulls apart each polygon and returns all the points (vertices) within the polygon's boundary.
Take note of the following:
(st_dumppoints(polygon.shape)).geom::geometry(Point,4326)
Calls the ST_DumpPoints function and then only the "geom" column returned by the function is kept. The type is explicitly cast. You will want to change that to the SRID of the "polygon" spatial column. (This isn't completely necessary, but I've found it to be good practice.)
row_number() OVER (ORDER BY (st_dumppoints(polygon.shape)).geom) AS objectid
Is necessary to create a unique identifier column, required by most desktop GIS applications, including QGIS.