Adding CSV layers as a spatial layer

“Spatial data identifies the geographic location of features and boundaries. The GIS relies on the geometry to render them. ”

GIS software can read and write different data formats. In most cases these formats have their geometry converted to a usable form and no extra steps are needed whilst adding them. CSV(Comma Separated Value) file is a delimited text file that uses a comma to separate values. CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. In this module, we will explore the contents of CSV files and how to add them to QGIS when they contain geographic information.

You try:

Goal: To load spatial data from a CSV into QGIS.

  • Navigate to the exercise folder.
  • Open the ports.csv file in a text editor or in excel to understand the contents of the layer.
  • Close the file after exploring the layer.
  • Use the Manage Layers toolbar to locate Add Delimited text layer
  • Navigate to the exercise folder and select the ports.csv
  • In the Geometry definition, select the appropriate column headings for X and Y.
  • If the CRS is not selected by default, choose EPSG:4326
  • Load the layer into QGIS.

Part B

  • Explore the CSV airports.csv.
  • Add a Delimited text layer and select the airports.csv.
  • In the Geometry definition select Well Known Text (wkt)
  • Add the layer into QGIS

Why were you able to add the airports into QGIS but they do not have the latitude, longitude column?

More about working with CSV

CSV file is a set of database rows and columns stored in a text file such that the rows are separated by a new line while the columns are separated by a semicolon or a comma. If the values stored in a CSV contains geographic data, the CSV file can be loaded into QGIS as a spatial layer. The geographic information can be in various formats.

Format Description
latitude and longitude Geographic co ordinates
wkt_text Well know text representation of a geometry
wkb Well Known binary representation of a geometry

If the CSV file contains latitude and longitude QGIS will convert this into point geometry. If you have played around with expressions in QGIS you can look at a function called make_point. This expression takes latitude and longitude as input and converts it into a point geometry.

Check your knowledge:

  1. Is it possible to load a CSV that does not contain geometry information to QGIS i.e no longitude or latitude columns:

    1. No
    2. Yes
  2. What is the easiest way to load an excel spreadsheet with geographic information to QGIS.:

    1. Use the Add Vector option and QGIS will convert it to a point layer
    2. Save the spreadsheet as a CSV and them load it into QGIS
    3. Export the data into a different software and convert it to shapefile.