I've build a toolbox in my project environment to plan "Aids to Navigation". The vessel (ship) that does the actual work in the field has a navigation computer that can only import waypoint. These waypoints are stored in a *.wpt file, that is just a text file with a few lines per waypoint.example of current method

So to make this file: I've prepared a layer that grabs the geometry from my planning tool and displays the data as a HTML maptip in the correct manner. I show all the waypoints I need (1 by 1), select the text, copy the text and paste it into a text-editor. After pasting all the waypoints in one file I save it as a .wpt file. This isn't a lot of work when designing small projects. But with 30+ mutations it isn't very efficient.

I am trying to come up with a manner to export all the data in one go to a text file in the *.wpt format. Can't find a plugin in QGIS or come up with a way to get this done


You can store all that information in one long text field, including the line breaks with '\n'.

  1. Use this expression in the Field Calculator to create a new textfield, called "printout".

    '[WAYPOINT(' || "WAYPOINT" || ')]' || '\n' ||
    'Type=' || "Type"
    'Xwp=' || $X || '\n' ||
    'Ywp=' || $Y || '\n' ||
    'Zwp=' || $Z || '\n' ||
    'Name=' || "Name" || '\n' ||
    'Tol1=' || "Tol1" || '\n' ||
    'Tol1=' ||  "Tol2"

    Make sure the field length is plenty long enough to store the longest possible combination of characters. Note: I'm assuming that you have fields called WAYPOINT, Type, Name, Tol1 and Tol2, and the Xwp, Ywp and Zwp values are just the X, Y and Z coordinates of the point.

    If you need another line break to separate the records, just add another || '\n' to the end of the expression.

  2. Export the layer as a CSV file. Unselect all columns other than "printout". Choose "no geometry".

    Here's what my test data looks like in WordPad (I only included the first few lines in my test, and the waypoint and type used fixed values):

    type = 0
    xwp = -1.0921658986175116
    ywp = 0.5975422427035331"
    type = 0
    xwp = -1.1013824884792625
    ywp = -0.053763440860215006"
    type = 0
    xwp = -0.8003072196620583
    ywp = -0.3609831029185868"

    I did find that if I opened the CSV in Notepad, the line breaks were not preserved.

  3. Open the CSV in your text editor of choice. Make any further edits as necessary (eg you might need to remove the column name, or the quotation marks, or insert a spacer between the waypoint sections). Save with the file extension .wpt.

  • this is an improvement. i changed the fields a bit. '[WAYPOINT(' || @row_number || ')]' || '\n' || 'Type=' || '0' || '\n' || 'Xwp=' || "UTM EAST" || '\n' || 'Ywp=' || "UTM NORTH" || '\n' || 'Zwp=' || '0' || '\n' || 'Name=' || "Name" || '\n' || 'Tol1=' || '0' || '\n' || 'Tol2=' || '0' It still needs a lot of work deleting " and adding spaces. – CaptainAhab Apr 15 at 21:15
  • 1
    Solved the space issue by changing the row names into 'Xwp = '. If i open the file with nano I can use the "find and replace" function to get rid of the ". – CaptainAhab Apr 15 at 21:44
  • I did my best based on the minimal information you provided. I'm glad you were able to figure it out from there. – csk Apr 16 at 16:18

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.