Pre-requisites:

  • Setup
  • Basics Overview

Objectives:

  • Understand the difference between a raster and a vector dataset.
  • Recognize a few spatial data formats.
  • Import and understand vector data in QGIS

Exercise: Introduction to vector data in QGIS


Vector

VectorBitmapExample ref: 1

Vector data uses features (features are usually points, lines or polygons) to represent discrete phenomena in the real world. For example, a vector data file might include a river represented by a line which is assigned a value. For data which is associated with discrete entities like countries, landmarks, roads, etc. vector data is the way to go.


Raster vector tikz ref: 2


Vector Data Types

The Geometry Object Model from the Simple Features for SQL specification:

This structure allowed developers to rely on a standard system for storing spatial data types and representing the relationships between different spatial data types.

Some of the most used spatial data types are:

Point
A Point is a 0-dimensional geometric object and represents a single location in coordinate space. A Point has an x-coordinate value, and a y-coordinate value. If called for by the associated Spatial Reference System, it may also have coordinate values for z and m.
LineString
A linestring is a Curve with linear interpolation between Points. Each consecutive pair of points defines a Line Segment. A line is a LineString with exactly 2 Points. A Linear Ring is a LineString is a LineString that is both closed and simple. A linestring is a series of connected points. These points act as vertices or nodes and are connected by curves. Each curve is assigned a start point and end point whcih represents the cardinality of the linestring. This cardinality is used to designate an order from the starting point to the end point.
Polygon
A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries. Each interior boundary defines a hole in the Polygon. Polygons are topologically closed. The boundary of a Polygon consists of a set of LinearRings that make up its exterior and interior boundaries. No two Rings in the boundary cross and the Rings in the boundary of a Polygon may intersect but only as a tangent. A series of connected LineStrings.

Data formats

  • Shapefile: Stores point, line, and polygon data. This file type is actually made up of a collection of files with the following endings: These are mandatory: .shp, .shx, .dbf There are many others which are optional, including the important .prj file that describes the projection information for that data.
  • File/Personal Geodatabase: Esri proprietary spatial database. Very easy to load data into, not so easy to extract. Newer version of QGIS (2.8) is configured by default to read proprietary Esri geodatabases.
  • GeoJSON: Encodes points, lines, and polygons (and collections of those) along with information about them using JSON (JavaScript Object Notation). This format is popular for web maps.

Exercise

This next exercise will explain the basics of importing, inspecting, and styling vector data using QGIS.

  1. Open QGIS and import vector data. Choose one of the following (iRods or Download zip):
    1. iRods access:
         /iplant/home/shared/aegis/Spatial-bootcamp/basics/vector

      1. iRods is accessed through the iRods tool icon, or Menu Bar > Plugins > iRods. If the iRods plugin does not display then you either don't have it installed, or it has been disabled.

        Once opened, enter your iPlant username and password:

        Spatial Data Bootcamp: QGIS - iRods

      2. Navigate to /iplant/home/shared/aegis/Spatial-bootcamp/basics/vector
      3. Within the /vector/ directory, click (to highlight) arizona_counties.shp, then import.

        Notice the other files also named arizona_counties, but have different file extensions (not .shp). These are the files that hold information about the shapefile, but we do not import these into QGIS. QGIS will read them through the .shp. So, only import .shp.

        Spatial Data Bootcamp: QGIS - import vector data through iRods


    2. The non-iRods method: download, unzip, and import arizona_counties.shp:

         Click to download:
         arizona_counties.zip

      1. Import the Arizona Counties shapefile by clicking the Add Vector Layer button in the Toolbar, or by navigating through Menu Bar > Add Layer > Add Vector Layer.

        Subsequent exercises will refer to adding data through the buttons in the Toolbar.

      2. Click Browse to locate the shapefile: arizona_counties.shp

        Reminder: A shapefile contains 5 files, however only open the *.shp extension in QGIS (or other GIS applications)

        QGIS - Add vector layer
      3. We are now visualizing counties in Arizona.

        Think about it: We are not actually visualizing the single boundary of Arizona, but the boundaries of its counties which complete the boundary of Arizona.

        Spatial Data Bootcamp: QGIS - viewing vector data
  2. View vector properties
    1. To view vector (and all layers) attributes, Right-click layer > Open Attribute Table

      Spatial Data Bootcamp: QGIS - view vector data attributes

      This data was extracted from Global Administrative Areas, which will be covered in Data Collection. This is simple boundary data; just gives us country, state, county name, and unique identifiers for each entry. Example uses of this type of data are: joining Census tabular data; visualizing boundaries; cutting satellite imagery to a desired area.

  3. Styling
    1. You're able to customize how our data is visualized. Styles (like a template) can also be exported and saved for later use.

      To style our arizona_counties layer: Right-click layer (layer list) > Properties > Style

      Spatial Data Bootcamp: QGIS - style vector layer

    2. You can change the symbolism of the data by clicking on the dropdown list (default option is Single Symbol) Spatial Data Bootcamp: QGIS - vector symbolism From the dropdown list, select CategorizedSpatial Data Bootcamp: QGIS - categorized symbolism

    3. Once in the Categorized menu, configure as follows:
      • Column: NAME_2
      • Color ramp: Random colors
      • Click Classify to add the data classifications from the column NAME_2.

      If you remember from looking at our Arizona counties attributes, you'll know that NAME_2 represents the county name of each county.

      Click Apply then OK to update changes.

      Spatial Data Bootcamp: QGIS - Arizona county categorized by county name

    4. Your map should now look similar to the one below; categorized by county name (NAME_2) with random colors.

      Spatial Data Bootcamp: QGIS - symbolized by county name

      You have now been introduced to shapefiles.

      Refer to this exercise in the event that you have trouble importing shapefiles into QGIS.

      Close your workspace- this will prompt to save your existing workspace; save if you must, else No.