220.127.116.11. Add delimited text layer (*.txt, *.csv)
In this section, a simple text file will be added to QGIS to visualize and analyse it spatially (for more information about this refer to section 18.104.22.168.):
- Open Layer.
- Choose Add Delimited Text or click the appropriate button from the Manage Layers toolbar (Table 5).
- Choose the source text file (in our case the comma delimited textfile points_table.csv).
- Give a name to the output layer (e.g. bees_colony_locations_tab) .
- Select the appropriate delimiters (e.g. semicolon or comma) and the columns containing the coordinates in East (X) and North (Y) according to Fig. 75.
- Click OK.
- Choose the CH1903/LV03 projection from the CRS selector list.
- Click OK.
- Go to File.
- Click Save Project.
As a result, the honey bee colonies are shown as point information on top of the Map View (Fig. 76). It is important to note, that this layer is loaded into QGIS and available for any display and map creation purpose and also some basic analysis, but not physically stored as geodata in the file system. To get the full functionality of a point vector file, save this layer e.g. as a shapefile by performing the following steps:
- Right-click the layer in the Map Legend (Fig. 68).
- Choose the Save as option in the context menu.
- Select a file format (in our case it will be an ESRI Shapefile).
- Select a target destination folder within the file system (e.g. with the filename bees_colony_locations.shp).
- If special text characters are included, choose an encoding that is suitable (e.g. for Western Europe utf-8 or latin1 are good options).
- Select the correct CRS (in our case it is CH1903 / LV03).
- Enable the option Add saved file to map (Fig. 77).
- Click OK.
A message (“Export to vector file has been completed”) will appear and the layer will be added on top of the Map Legend.
- Select the old text file from the Map Legend using a left mouse click.
- Press the button remove layer(s)
(see Table 5) to remove it from the project – we will only need our newly
created shapefile for all future steps.
Fig. 75. Create a Layer from delimited text files: By the use of coordinates stored in different columns of a delimited text file, point vector files can be created.
Fig. 76. The map result after import of the honey bee colony locations (red dots). Reproduced with permission of Swisstopo (BA13016).
Fig. 77. Dialog window to save an existing layer as a new vector layer. By the use of this function, file format conversions and even transformations between different coordinate reference systems are possible (defining the target CRS).