How to plot location data from a CSV file as points on QGIS

This tutorial will provide step-by-step directions on how to visualize location data from The ScrapeHero Data Store using the open-source GIS software QGIS. 

What is QGIS?

QGIS, previously known as Quantum GIS, is a free, open-source Geographic Information System (GIS) software. It can be downloaded for free for Windows, Mac, Linux, BSD, and mobile devices (for downloading and installing instructions please click here).

QGIS helps create, edit and visualize geospatial data. It also enables a  wide range of different spatial data analyses using different tools and plugins available with QGIS (for more QGIS tutorials, click here).

Location Data for Visualization

We will use one of the store location datasets from the ScrapeHero Data Store. For this tutorial, we will use the complete list of Subway store locations in the United States. This data contains each store’s latitude and longitude coordinates, which you can plot as points over a map. You can download a sample CSV file or buy the full data from the link below. 

Subway store locations in the USA

Visualizing point data over the base map

 

point data over OSM in QGIS title

The easiest way to understand the store location data better is to plot it as a map. When we plot locations on a 2D surface, the points’ spatial relationships, such as their proximity to each other or aggregation, are easily understood. Furthermore, when we plot points above a base map, we can attain more information about the data points by simple visual interpretation. You can know in which city the stores are located, the nearby towns, roads, lakes or similar geographical features adjacent to the store, and many more.

The steps to place the point data over the base map of a region/country are:

  1. Import the base map
  2. Import the CSV file downloaded from the ScrapeHero store as a point vector
  3. Edit the symbology and label appropriately
  4. Export the map from QGIS to an image or a PDF

Here is a quick video on how to do this if you are in a hurry

Import the base map

The Base map layer provides background details like roads, points of interest (POI), building footprints, rivers, etc.

We will use OpenStreetMaps (OSM) as our base map as it the default in QGIS. You can use many other similar base maps like Google Maps, Mapbox, Bing Maps, etc.

Go to the Layers tab from main toolbar, select Add Layer > Add XYZ Layer > Select OpenStreetMap > Add:

You can see OSM added as a layer in the QGIS layers tab and seen in the map canvas area.

add OpenStreetMap to QGIS

Import the CSV file as a point vector

Once we add the base map, we need to import the store location data as a point vector layer. The CSV file from ScrapeHero appears as shown when opened in Excel. Each record in the table has the fields Latitude and Longitude, based on which we can plot the points on the map. 

view CSV in excel

 

Latitude and Longitude fields are the coordinates, and each record in the table will get added as a point vector. We will add a new ‘Delimited text layer’ and assign Longitude as the X coordinate and Latitude as the Y coordinate

Go to the Layers tab from the main toolbar, select Add layer > Add Delimited Text Layer

import CSV as Delimited Text Layer in QGIS

The ‘Data Source Manager’ window that pops up, browse for the ScrapeHero CSV file as File name. Select the Longitude and Latitude as X field and Y field, respectively. Also, select the respective Geometry CRS (coordinate reference system) based on the area or country used. For The United States, EPSG 4326 – WGS 84 is generally used.

import CSV select X Y fields

Clicking on the Add button should add many points as a layer of the Store Locations over the base map. Right-click the point data layer and select the ‘Zoom to Layer’ option, and then pan the image to view as required:

zoom to layer in QGIS

Edit symbology and label appropriately

Next, let’s edit the symbology of the point vector layer to make the map more elegant. Symbology here means the Size, Colors, Shape, etc., of the symbols used for each point.

Right-click the point data layer, select properties, and go to the Symbology tab.

edit symbology in QGIS

From the symbology window, Select the ‘Single Symbol’ option. Edit the size, color, and type of symbol to be used as required.

From the symbology window, Select the ‘Single Symbol’ option. Edit the size, color and type of symbol to be used as required.

To give a label corresponding to each point data, right-click the point data layer, select properties, and go to the Label option. Here we can select the field to be added as the label and edit other properties of the label added.

edit labels in QGIS

Select ‘Single Labels‘ and then the ‘Value‘ field from the table as the label. Here, the ‘name’ of the store is labeled corresponding to each location. Configure the font, font color, font size, opacity, and other attributes as you like.

edit labels in QGIS menu

We should get the store location map after editing symbology and labels somewhat similar to what we have below:

point data over OSM in QGIS

 

Export the map as an Image or PDF 

We can export the map viewed over the Image canvas area of QGIS as a PDF or an Image (png). In this tutorial, we are exporting only a part of the whole map. To export the entire map, you can right-click the image layer and select the ‘Zoom to Layer‘ option. In that case, you can turn off the labels for a better appearance.

For now, we will export only a basic map without adding other map elements. You can add legends, scale, north arrows, and other map elements in QGIS if required.

To export in PDF or PNG formats, first, zoom and pan the image over the canvas.

Go to Project> Import/Export > Export as Image for png format or Export as PDF to get the final map in PDF format.

export map to pdf in QGIS

 

That’s it!

 

Posted in:   Data Visualization Tutorials, ScrapeHero Data Store Resources, Tutorials

Leave a Reply

Your email address will not be published. Required fields are marked *

Turn the Internet into meaningful, structured and usable data   

ScrapeHero Logo

Can we help you get some data?