Geographic Information Systems Asked by hearsay on May 28, 2021
I want to keep an Excel sheet containing flight records. Then I want to use QGIS to plot the coordinates. I would like to keep all data for each flight on one line. Is this possible?
When I add a CSV layer it will only allow me to plot X and Y coordinates. Which in the case of my data is my origin airport. It will not plot the destination coordinates unless I put that data on a separate row using the same X and Y plots. What is the best way for me to organize my data?
QGIS has only one real geometry per feature. To get around this, the easiest way is to use the Geometry Generator.
Import the CSV using origin_laty
and origin_lonx
as the X and Y geometry columns. Your layer will now show the origin point. You can style it in the symbology settings as you wish.
Now add a new symbol layer in the symbology, and make the symbol layer type be Geometry Generator, geometry type LineString. In the expression window (where it probably just says $geometry
as a default), enter
make_line( $geometry ,
make_point( "destination_lonx" , "destination_laty" ) )
Go ahead and style this line symbol layer to show the connecting line.
Finally, if you wish, add a 2nd Geometry Generator symbol layer, of point type, with just the expression
make_point( "destination_lonx" , "destination_laty" )
To display the destinations.
If you felt like it, you could create a virtual field Destination
in the field list using the Field Calculator, and use the make_point(...)
expression to populate it, and then use it as an attribute in the above 2 symbol layers. This saves it being recalculated twice, and you could use it for other purposes too, but for a simple CSV layer is hardly worth the effort.
Editing to add: I see J.R answered in line with my answer while I was typing it. Keeping mine up since I explicitly wrote out the expressions, just in case that's useful.
Additional option. If the visibility issues J.R. mentions (and I've experienced too...) become a concern, you could also preprocess the CSV in Excel (or wherever) and create another calculated column there with the connecting line in WKT. See my answer at Creating multiple separate vector lines from list of coordinate pairs in QGIS
Correct answer by Houska on May 28, 2021
Your data are perfectly organised.
Just do as before then to get line from your start and end coordinate you could use :
If you want to have symbol on the start or end point you could add symbol layer and use again the geometry generator with the make_point expression.
Answered by J.R on May 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP