More

Visualising WKT geometry string in QGIS

Visualising WKT geometry string in QGIS


A very simple question: Is there a simple tool in QGIS to graphically visualise geometry formatted as text?

Example geometry:

"POLYGON((571178 6337246,571178 6402217,598061 6402217,598061 6337246,571178 6337246))"

Result:

A layer in QGIS showing the polygon from above.

The intention is to do quick and dirty visualisation for debugging purposes - I feel it is easier to relate to a graphical representation than a coordinate list.


Current answer

Try "QuickWKT" Plugin.

Old answer

Try "QuickWKT" plugin. You have to allow experimental plugins to be able to install it.


Indeed there is! Look here for how to achieve it with the Add Delimited Text Layer plugin.

Essentially you create a CSV file (although you should use a delimiter other than comma), where one column is the WKT representation of your geometry. Then when you select that file in the plugin, it picks up that there is a WKT column, and does the right thing.

I can't vouch for its robustness, but the sample you gave works fine:

id|wkt 1|POLYGON((571178 6337246,571178 6402217,598061 6402217,598061 6337246,571178 6337246))


No Plugin needed

In QGIS deploy a "Virtual Layer" throughLayer > Add Layer > Add/Edit Virtual Layer….
In the Query window simply paste the following expression:

SELECT ST_GeomFromText('POLYGON((571178 6337246,571178 6402217,598061 6402217,598061 6337246,571178 6337246))')

or with an SRID code

SELECT ST_GeomFromText('POLYGON((571178 6337246,571178 6402217,598061 6402217,598061 6337246,571178 6337246))', 4326)

The result might look like this


References:


Quick and dirty: select the record in the table of attributes, ctrl-c and then paste with ctrl-v in a text editor. Along with attributes you will see also the geometry as text.

Probably there are more elegant alternatives.