3

I want to classify a gpx file by elevation in QGIS.

This is what I have done:

  1. Imported track_points from gpx file (because only this part of file containes elevations)

  2. Saved that file as shp (just in case)

  3. Classified shp as categorized

Now I would like to connect points as line but I would like to preserve categorization color of points. I have tried the plugins Points2one and Recostruction Line. But I haven't had luck and I also got errors in some cases.

Images below

Left: what I have achieved Right: created line by IDs with Points2one plugin (colors are not preserved) enter image description here

EDIT

After suggestion given by mgri I end up having this in SAGA:

enter image description here * I have tried to choose couple of combinations

Result:

enter image description here

1 Answer 1

5

I don't know it is possible to achieve what you are asking because you don't know how to proceed when you pass from a category to another one. I will explain it with an example.


You may try using the Convert points to line(s) SAGA tool from Processing Toolbox: it leads the creation of lines starting from a point layer for which you specify the order for the creation of the line features and how to separate them.

Starting from this point layer:

enter image description here

which stores its ids in the "FID" field and the categories in the "AUTO" field:

enter image description here

You may run the above tool by setting the "FID" field as Order by... parameter and the "AUTO" field as Separate by... parameter.

You will get this result:

enter image description here

which still stores the "AUTO" field (so, you can still apply the classification).

As I specified above, it is correct that a line is not created when passing from a category to the next one because QGIS doesn't know what to do. Starting from this result, you should, however, be able to add some feature lines with custom values for completing the task.

EDIT

If you have many elevation values, you may create a new field which stores a classification of them. For doing this, create a new field and then, in the field calculator, use this expression (the following values are an example):

CASE
WHEN
"Altitude" <= 300
THEN
"Altitude_range" = 0
WHEN
"Altitude" > 300 AND "Altitude" <= 600
THEN
"Altitude_range" = 1
WHEN
"Altitude" > 600 AND "Altitude" <= 900
THEN
"Altitude_range" = 2
END

where "Altitude" is the field in you point shapefile which stores the altitudes and "Altitude_range" is the name of the new field (adapt the name and the code to your case).

The following image will help to undestand:

enter image description here

18
  • At what point I will end up having AUTO field. I assume in the beginning. Gpx track is recorded with Geo Tracker. I dont have that field anywhere. Commented Mar 28, 2017 at 22:00
  • @newbie_girl Sorry, I didn't specify that you need to use the field that you used for the classification of the points instead of mine (the "AUTO" field is only an example). The same for the FID field: you need to use the field in your shapefile that stores the ids.
    – mgri
    Commented Mar 28, 2017 at 22:05
  • so i have...order by: id, separate by: elevation. this is unfortunally impossible because of the elevation that varies from 600 to 900 m. I dont have unique segments for classification, althought I am not sure if I have saved file correctly from QGIS because style is not imported right in SAGA. I have sld from shp, with same name, but I dont see SAGA is reading it. Commented Mar 28, 2017 at 22:21
  • For the issue with SAGA, try selecting a different field from the one initially proposed by the tool and then try to set again the field you want to use: it should work. For the problem about the elevation, see the edit on my answer.
    – mgri
    Commented Mar 28, 2017 at 22:28
  • 2
    @mgri I too hate dirty quickies, I like good structured script, making sure everything is perfectly done :)
    – gisnside
    Commented Mar 29, 2017 at 15:08

Your Answer

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

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