QGIS – How to Import CSV as Polygon in QGIS

csvpolygonqgis

I have a CSV file with the coordinates of the vertices of my polygons (in the picture they correspond to "left", "right", "top", "bottom"). Actually is a grid of polygons. How can I import the file in QGIS as polygons and not as points?

enter image description here

Best Answer

You can do it with expressions, even loading your excel file, without converting to .csv, load your excel file as if it was a vectorial layer

On the process toolbox > vector geometry > geometry by expression. enter image description here

enter image description here

The expression, although it looks a little long, is simply to write a wkt polygon using the fields, then you convert it to geometry. enter image description here

Simply run this expression

 geom_from_wkt( concat('POLYGON((',to_string("left")+' '+to_string("top")+',',to_string("right")+' '+to_string("top")+', ', to_string("right")+' '+to_string("bottom")+',', to_string("left")+' '+to_string("bottom"),'))

You will get a result like this:

enter image description here