1

I've been working on deriving bearings and distances from lines in qgis 2.18 from a number of coordinates stored as a csv file. I have been able to generate the bearing of the lines using this expression in the field calculator:

CONCAT(format_number(degrees(azimuth(start_point($geometry), end_point($geometry))), 2), '°')

But this expression does not allow the bearing to be added in the attribute table (or i simply dont know how to do that). Can anyone help?

1
  • Welcome to GIS SE. Could you please explain more what you have as inputs? Do you want to add a column in the csv file ? Where did you store the bearings at present if not in an attribute table? Maybe you want to join ? Do you have an error message (maybe you try to store text in a numeric field)
    – radouxju
    Nov 16, 2018 at 7:30

2 Answers 2

1

Assuming you are using the field calculator and creating a new field, this works just fine. Therefore, I suspect that you have not specified your firld type as Text and left it as the default Whole number (Integer). Remember you are concatenating numeric values with the degree sign - which is text and the result is text.

0
0

CSV files can't be edited in QGIS.

Save the layer in a different format such as shapefile or geopackage. Load the file you just created into QGIS. You will be able to add fields to this layer using the Field Calculator.

If you need this file in CSV format, you have two options:

  1. Work with the data in a QGIS-compatible format (as described above). When you're finished making changes, export the data to CSV format.

  2. Install the Editable GeoCSV plugin. This plugin should allow you to directly edit the CSV file without first converting it to shapefile or other compatible format. It might be a good idea to make a backup copy of the CSV file before using the plugin, just in case it changes your file in a way you don't like.

Related: Why can't I edit attribute table imported through 'text as layer'

2
  • thank you @csk, shud have saved it as a shapefile first
    – GeomaSmart
    Nov 17, 2018 at 7:07
  • If my answer resolved your issue, please click the check mark to mark it as "accepted."
    – csk
    Nov 19, 2018 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.