5. Getting Started

This chapter provides a quick overview of installing QGIS, downloading QGIS sample data, and running a first simple session visualizing raster and vector data.

5.1. Installing QGIS

QGIS project provides different ways to install QGIS depending on your platform.

5.1.1. Installing from binaries

Standard installers are available for win MS Windows and osx macOS. Binary packages (rpm and deb) or software repositories are provided for many flavors of GNU/Linux nix.

For more information and instructions for your operating system check https://download.qgis.org.

5.1.2. Installing from source

If you need to build QGIS from source, please refer to the installation instructions. They are distributed with the QGIS source code in a file called INSTALL. You can also find them online at https://github.com/qgis/QGIS/blob/master/INSTALL.md.

If you want to build a particular release and not the version in development, you should replace master with the release branch (commonly in the release-X_Y form) in the above-mentioned link (installation instructions may differ).

5.1.3. Installing on external media

It is possible to install QGIS (with all plugins and settings) on a flash drive. This is achieved by defining a --profiles-path option that overrides the default user profile path and forces QSettings to use this directory, too. See section System Settings for additional information.

5.1.4. Downloading sample data

This user guide contains examples based on the QGIS sample dataset (also called the Alaska dataset). Download the sample data from https://github.com/qgis/QGIS-Sample-Data/archive/master.zip and unzip the archive on any convenient location on your system.

The Alaska dataset includes all GIS data that are used for the examples and screenshots in this user guide; it also includes a small GRASS database. The projection for the QGIS sample datasets is Alaska Albers Equal Area with units feet. The EPSG code is 2964.

PROJCS["Albers Equal Area",
GEOGCS["NAD27",
DATUM["North_American_Datum_1927",
SPHEROID["Clarke 1866",6378206.4,294.978698213898,
AUTHORITY["EPSG","7008"]],
TOWGS84[-3,142,183,0,0,0,0],
AUTHORITY["EPSG","6267"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9108"]],
AUTHORITY["EPSG","4267"]],
PROJECTION["Albers_Conic_Equal_Area"],
PARAMETER["standard_parallel_1",55],
PARAMETER["standard_parallel_2",65],
PARAMETER["latitude_of_center",50],
PARAMETER["longitude_of_center",-154],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["us_survey_feet",0.3048006096012192]]

If you intend to use QGIS as a graphical front end for GRASS, you can find a selection of sample locations (e.g., Spearfish or South Dakota) at the official GRASS GIS website, https://grass.osgeo.org/download/sample-data/.

5.2. Starting and stopping QGIS

QGIS can be started like any other application on your computer. This means that you can launch QGIS by:

  • using nix the Applications menu, win the Start menu, or osx the Dock

  • double clicking the icon in your Applications folder or desktop shortcut

  • double clicking an existing QGIS project file (with .qgz or .qgs extension). Note that this will also open the project.

  • typing qgis in a command prompt (assuming that QGIS is added to your PATH or you are in its installation folder)

To stop QGIS, use:

  • nix win the menu option Project ► Exit QGIS or use the shortcut Ctrl+Q

  • osx QGIS ► Quit QGIS, or use the shortcut Cmd+Q

  • or use the red cross at the top-right corner of the main interface of the application.

5.3. Sample Session: Loading raster and vector layers

Now that you have QGIS installed and a sample dataset available, we will demonstrate a first sample session. In this example, we will visualize a raster and a vector layer. We will use:

  • the landcover raster layer (qgis_sample_data/raster/landcover.img)

  • and the lakes vector layer (qgis_sample_data/gml/lakes.gml)

Where qgis_sample_data represents the path to the unzipped dataset.

  1. Start QGIS as seen in Starting and stopping QGIS.

  2. To load the files in QGIS:

    1. Click on the dataSourceManager Open Data Source Manager icon. The Data Source Manager should open in Browser mode.

    2. Browse to the folder qgis_sample_data/raster/

    3. Select the ERDAS IMG file landcover.img and double-click it. The landcover layer is added in the background while the Data Source Manager window remains open.

      ../../../_images/add_raster1.png

      图 5.1 Adding data to a new project in QGIS

    4. To load the lakes data, browse to the folder qgis_sample_data/gml/, and double-click the lakes.gml file to open it.

    5. A Coordinate Reference System Selector dialog opens. In the Filter menu, type 2964, filtering the list of Coordinate Reference Systems below.

      ../../../_images/selectCRS.png

      图 5.2 Select the Coordinate Reference System of data

    6. Select the NAD27 / Alaska Albers entry

    7. Click OK

    8. Close the Data Source Manager window

You now have the two layers available in your project in some random colours. Let's do some customization on the lakes layer.

  1. Select the zoomIn Zoom In tool on the Navigation toolbar

  2. Zoom to an area with some lakes

  3. Double-click the lakes layer in the map legend to open the Properties dialog

  4. To change the lakes color:

    1. Click on the symbology Symbology tab

    2. Select blue as fill color.

      ../../../_images/selectFillColor.png

      图 5.3 Selecting Lakes color

    3. Press OK. Lakes are now displayed in blue in the map canvas.

  5. To display the name of the lakes:

    1. Reopen the lakes layer Properties dialog

    2. Click on the labeling Labels tab

    3. Select Single labels in the drop-down menu to enable labeling.

    4. From the Label with list, choose the NAMES field.

      ../../../_images/showLabels.png

      图 5.4 Showing Lakes names

    5. Press Apply. Names will now load over the boundaries.

  6. You can improve readability of the labels by adding a white buffer around them:

    1. Click the Buffer tab in the list on the left

    2. Check checkbox Draw text buffer

    3. Choose 3 as buffer size

    4. Click Apply

    5. Check if the result looks good, and update the value if needed.

    6. Finally click OK to close the Layer Properties dialog and apply the changes.

Let's now add some decorations in order to shape the map and export it out of QGIS:

  1. Select View ► Decorations ► Scale Bar menu

  2. In the dialog that opens, check checkbox Enable Scale Bar option

  3. Customize the options of the dialog as you want

  4. Press Apply

  5. Likewise, from the decorations menu, add more items (north arrow, copyright...) to the map canvas with custom properties.

  6. Click Project ► Import/Export ► saveMapAsImage Export Map to Image...

  7. Press Save in the opened dialog

  8. Select a file location, a format and confirm by pressing Save again.

  9. Press Project ► fileSave Save... to store your changes as a .qgz project file.

That's it! You can see how easy it is to visualize raster and vector layers in QGIS, configure them and generate your map in an image format you can use in other softwares. Let's move on to learn more about the available functionality, features and settings, and how to use them.

备注

To continue learning QGIS through step-by-step exercises, follow the Training manual.