You will need to do some formatting of your data to make them into polygons. Merely labeling a field as WKT will not help. If you have a lot of files (which it sounds like you do), the most effective way will be to automate your solution by writing a script.
I was going to explain how when I decided that the simplest way would be to write an example script (apologies if I am teaching you to suck eggs!):
import os
csvFolder = r"C:\myFolder\mySubFolder"
#----------------------------------------
def writePolyToFile(outFile, polygon, polyId):
wkt = "POLYGON((" + ','.join(polygon) + "))\n"
outFile.write(str(polyId) + ';' + wkt)
def makePolys(inPath, outPath):
try:
with open(inPath,'r') as inFile:
contents = inFile.readlines()
polyId = 0
polygon = []
for line in contents:
line = line.rstrip('\n')
if polyId == 0:
if line != 'x,y':
print("Unexpected file contents detected in", inPath)
break
outFile = open(outPath,'w')
outFile.write("id;wkt\n")
polyId += 1
elif len(line) == 0:
writePolyToFile(outFile, polygon, polyId)
polygon = []
polyId += 1
else:
polygon.append(line.replace(',',' '))
writePolyToFile(outFile, polygon, polyId) #append the last polygon after EOF
outFile.close()
print('Conversion to WKT OK for', inPath)
except:
print('WARNING: conversion to WKT failed for', inPath)
def iterateFiles():
csvFiles = [each for each in os.listdir(csvFolder) if each.endswith('.csv')]
for file in csvFiles:
inPath = os.path.join(csvFolder, file)
newName = "WKT_" + file
outPath = os.path.join(csvFolder, newName)
makePolys(inPath, outPath)
#---------------------------------------------
if __name__ == "__main__":
iterateFiles()
This is a very simple Python script which will iterate over a folder of CSV files as a batch process. It does a crude logic check that the first line of the file follows your format of 'x,y'. It then collects all the points into an array until it finds a blank line and recasts the array as a WKT string which it writes to an output file of the same name as the original but prefixed by 'WKT_' (so 'firstFile.csv' exports to 'WKT_firstFile.csv' preserving the original file).
Change the following line csvFolder = r"C:\myFolder\mySubFolder" to point to a folder containing all the CSV files your want to convert (make sure you keep that 'r' at the start of the path!).
You can now open the resulting files using the normal 'Add vector layer' dialog instead of the 'Add delimited text' dialog.
EDIT
Here is a sample of my test:
Input:
x,y
10,10
20,20
20,30
10,10
5,5
5,6
6,5
5,5
15,15
30,30
30,40
15,15
Output:
id;wkt
1;POLYGON((10 10,20 20,20 30,10 10))
2;POLYGON((5 5,5 6,6 5,5 5))
3;POLYGON((15 15,30 30,30 40,15 15))
Best Answer
Use Arrows style instead of Simple Line style.
For example, these lines with Simple Line style:
look like this with Arrow style:
You can turn off the arrow heads by setting the head width and length to 0.
As you can see, the straight line becomes a straight arrow, while the lines with a middle vertex become curved arrows. The placement of the middle vertex determines the curve of the arrow.
To convert your straight lines to curved arrows, you'll need to add a middle vertex to every line, and then offset that vertex enough to generate a curved arrow.
Use the Geometry Generator style with Geometry type: Linestring. This expression will create a line with a midpoint 200 distance units to the east and north of the original midpoint of the line.
Change the line to display as an Arrow style. Adjust the centroid offset values in the geometry generator expression until you're happy with the shape of the arrows. If you want, you can make them proportional to the length of the original line, eg
$length/10
. The full expression would be:Here's what it looks like, with the original lines in pink and the geometry-generated arrows in black:
If you aren't satisfied with the line midpoint placement, you can adjust them manually. First, convert the geometry generated line style into an actual layer. Copy the expression from the geometry generator into the
geometry by expression
tool (Processing toolbox). Then use the Vertex Tool (Digitizing toolbar) to manually move the vertices.Note: This answer was made with QGIS 3.4.