This tutorial will provide step-by-step directions on how to visualize location data from The ScrapeHero Data Store as a choropleth map using the open-source GIS software 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.
Visualizing point data over the base map
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:
- Import the base map
- Import the CSV file downloaded from the ScrapeHero store as a point vector
- Edit the symbology and label appropriately
- 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.
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.
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
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.
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:
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.
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.
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.
We should get the store location map after editing symbology and labels somewhat similar to what we have below:
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.