Jump to content

Wikipedia:Graphics Lab/Resources/QGIS/Get ready

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Yug (talk | contribs) at 16:53, 23 September 2011 (Topography/bathymetry). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
The QGis interface. QGis can import GIS data—high quality topographic backgrounds, shaded reliefs, and administrative regions or borders—and apply styles to them.
Map with imported GIS data: topographic background, shaded relief, administrative borders, roads. The labels, icons, and legend are easily added later using Inkscape.
Made using GIS data 'ETOPO1', QGis, this QGis tutorial, Inkscape, and the Wikipedia map conventions. Late Spring and Autumn Period, 5th centry BCE, before the breakup of Jin and the Qin move into Sichuan.

QGis (full name: Quantum GIS) is a GPL license, cross-platform (Windows, Linux, Mac), and rather friendly cartographic software application. It is a Geographic Information System (GIS) program you can use to create, view, and analyze maps. In a nutshell, a GIS associates with each geographic coordinate (dot) on Earth a specific value from some survey. The best example of this is altitude: a topographic map, like the ones you see on the right, can be created from a GIS file in which each pixel represents not only a geographic coordinate, but also information about its altitude. Reversely, objects can be placed on a map and associated with specific coordinates; this is commonly used for features such as roads, bodies of water, state or province borders, urban areas, etc. As a result, these features are georeferenced on separate layers and their shape and location match their actual appearance on the surface of the Earth.

This approach radically changes the process of making maps. Formerly, the mapmaker or graphist had to personally draw each layer of a map, then combine them into an image. The work's reliability and precision were limited by the user's resources and knowledge. Now, the mapmaker can collect precise GIS data from reliable sources and simply load them into QGis. Objects will be automatically placed in their exact coordinates, allowing the user to apply custom styles and output an accurate basemap, which may be the end product, or a background to host additional custom layers (icons, labels, a legend, etc.). For Wikipedia, the advantages of GIS maps are precision, reliability, consistency, and an upgrade in visual elegance of the final images. Using QGis will be mainly helpful in generating topographic backgrounds (png, svg), shaded reliefs (png), and administrative regions or borders (png, svg), and applying various styles to them.

While GRASS GIS still seems to be the most common GIS software, it has a primarily command-line interface and can be difficult to learn and operate. Therefore, beginners will prefer QGis, which is quite powerful and user-friendly. It integrates GRASS GIS and GDAL, provides an easier to use interface for GRASS GIS, and gives the user an opportunity to improve his or her GIS mapmaking skills.

This tutorial series will teach you how to use QGis to generate reliable maps for Wikipedia. Accordingly, it is Wikipedia-centered and focuses on outputting general public encyclopedic maps while following the Wikipedia map conventions.

If you would like a more comprehensive overview of QGis and its functions, you can read the official User Guide, available in several languages.

Step 1: Get the tools

Install QGis

Find your operating system from the list below and follow the link to the appropriate installer. Please don't install the sample data sets (North Carolina, etc.); you will be downloading more complete data later.

  • Windows (Standalone Installer) (fr, de) – You can also watch a video demonstrating the installation process [1], but be advised that it is out of date and describes currently inaccurate file sizes and download times.
  • Linux (fr, de)
  • MacOS X (FrameWorks) (fr, de)

While QGis will allow you to open many GIS files, we are mainly concerned with .tiff (raster) and .shp (vector) files.

Create some helpful folders

On your desktop, or some other suitable place, create the following folders:

→ QGis

→ Data_ETOPO1
→ Data_SRTM3v2
→ Shaded
→ Data_Naturalearth.com
→ (Data_... [other source folders as needed])
→ Tutorials
→ Mapcolors
→ Projects
→ Examples
→ Outputs
→ [others as needed]
  • You need separate Data_[sourcename] folders because data sets from each source may have different copyright status, coverage quality, or subjects (topography, political boundaries, etc.), and are usually made of dozens of files/tiles. Separate folders for each source will help you keep the files together and the sets organized.
  • Tutorials will host any interesting tutorials (webpages, PDF, etc.) you may find, which you can then edit or take notes on.
  • Any color styles you will find online or create yourself can be saved into Mapcolors.
  • Your QGis projects will be saved in the Projects folder.
  • Examples let's you collect any maps on Wikipedia that you like and want to study (reverse engineering).
  • Outputs will host the many intermediate outputs you will generate and look at to improve your mapmaking skills, as well as any finished maps you create.

Save your first color style

Copy-paste the following color code in an empty, plain text document (using something like Notepad or TextEdit), then save it in ./QGis/Mapcolors/ as Wikicarto_2.0.qml. We will frequently use it later.

: Colormap "Wikicarto_2.0.qml"
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="1.6.0-Copiapo" minimumScale="1" maximumScale="1e+08" hasScaleBasedVisibilityFlag="0">
  <transparencyLevelInt>255</transparencyLevelInt>
  <rasterproperties>
    <mDrawingStyle>SingleBandPseudoColor</mDrawingStyle>
    <mColorShadingAlgorithm>ColorRampShader</mColorShadingAlgorithm>
    <mInvertColor boolean="false"/>
    <mRedBandName>Not Set</mRedBandName>
    <mGreenBandName>Not Set</mGreenBandName>
    <mBlueBandName>Not Set</mBlueBandName>
    <mGrayBandName>Bande 1</mGrayBandName>
    <mStandardDeviations>0</mStandardDeviations>
    <mUserDefinedRGBMinimumMaximum boolean="false"/>
    <mRGBMinimumMaximumEstimated boolean="true"/>
    <mUserDefinedGrayMinimumMaximum boolean="false"/>
    <mGrayMinimumMaximumEstimated boolean="true"/>
    <mContrastEnhancementAlgorithm>StretchToMinimumMaximum</mContrastEnhancementAlgorithm>
    <contrastEnhancementMinMaxValues>
      <minMaxEntry>
        <min>-10458</min>
        <max>6741</max>
      </minMaxEntry>
    </contrastEnhancementMinMaxValues>
    <mNoDataValue mValidNoDataValue="false">-9999.000000</mNoDataValue>
    <customColorRamp>
      <colorRampType>DISCRETE</colorRampType>
      <colorRampEntry red="245" value="8000.000000" green="244" blue="242" label="altitude 19 neiges eternelles"/>
      <colorRampEntry red="224" value="7000.000000" green="222" blue="216" label="altitude 18 neiges eternelles"/>
      <colorRampEntry red="202" value="6000.000000" green="195" blue="184" label="altitude 17 neiges eternelles"/>
      <colorRampEntry red="186" value="5000.000000" green="174" blue="154" label="altitude 16 neiges eternelles"/>
      <colorRampEntry red="172" value="4000.000000" green="154" blue="124" label="altitude 15 neiges eternelles"/>
      <colorRampEntry red="170" value="3000.000000" green="135" blue="83" label="altitude 14"/>
      <colorRampEntry red="185" value="2000.000000" green="152" blue="90" label="altitude 13"/>
      <colorRampEntry red="195" value="1500.000000" green="167" blue="107" label="altitude 12"/>
      <colorRampEntry red="202" value="1000.000000" green="185" blue="130" label="altitude 11"/>
      <colorRampEntry red="211" value="800.000000" green="202" blue="157" label="altitude 10"/>
      <colorRampEntry red="222" value="600.000000" green="214" blue="163" label="altitude 9"/>
      <colorRampEntry red="232" value="400.000000" green="225" blue="182" label="altitude 8"/>
      <colorRampEntry red="239" value="300.000000" green="235" blue="192" label="altitude 7"/>
      <colorRampEntry red="225" value="200.000000" green="228" blue="181" label="altitude 6"/>
      <colorRampEntry red="209" value="150.000000" green="215" blue="171" label="altitude 5"/>
      <colorRampEntry red="189" value="100.000000" green="204" blue="150" label="altitude 4"/>
      <colorRampEntry red="168" value="50.000000" green="198" blue="143" label="altitude 3"/>
      <colorRampEntry red="148" value="20.000000" green="191" blue="139" label="altitude 2"/>
      <colorRampEntry red="172" value="1.000000" green="208" blue="165" label="altitude 1"/>
<!--      <colorRampEntry red="167" value="0.000000" green="223" blue="210" label="depression"/> -->
      <colorRampEntry red="216" value="0.000000" green="242" blue="254" label="altitude -1"/>
      <colorRampEntry red="198" value="-20.000000" green="236" blue="255" label="altitude -2"/>
      <colorRampEntry red="185" value="-50.000000" green="227" blue="255" label="altitude -3"/>
      <colorRampEntry red="172" value="-100.000000" green="219" blue="251" label="altitude -4"/>
      <colorRampEntry red="161" value="-250.000000" green="210" blue="247" label="altitude -5"/>
      <colorRampEntry red="150" value="-500.000000" green="201" blue="240" label="altitude -6"/>
      <colorRampEntry red="141" value="-750.000000" green="193" blue="234" label="altitude -7"/>
      <colorRampEntry red="132" value="-1000.000000" green="185" blue="227" label="altitude -8"/>
      <colorRampEntry red="121" value="-2000.000000" green="178" blue="222" label="altitude -9"/>
      <colorRampEntry red="113" value="-4000.000000" green="171" blue="216" label="altitude -10"/>
    </customColorRamp>
  </rasterproperties>
</qgis>

Step 2: Download the GIS data

Types of data

Topography/bathymetry

Quality comparison between ETOPO1 (pixelated) and SRTM3 (smoother) data sets. This difference doesn't matter for making large maps with coverage greater than 1000km (~620mi) across.
  • Great for maps conventions ! NGDC-NOAA: ETOPO1 (2009, Public domain). Specifics: topography & bathymetry layer(s), 1px= 1850m (1minute arch), all Earth (90N-90S, landmass & sea floor), projection (?), datum WSG 84. Files: compressed file 326Mo, uncompressed file 900Mo, whole earth, 1 tiles. —♣ Comment(s): Perfect for very large maps (ex: > France). Download: ETOPO1 Ice Surface (grid registered), ETOPO1 Bedrock (grid-registered). nb: ETOPO1 is a better data than ETOPO2 (lower quality).
  • Great for maps conventions ! NASA / USGS: SRTM3 (2000, Public Domain). Specifics: topography layer(s), 1px= 93m (3"arch), 60⁰N-56⁰S (landmass only), datum WGS 84. Files: on command, 1 tiles. —♣ Comment(s): Perfect for small areas anywhere in the world. Need to create a free account. Worth it. You will use this source frequently.

Other GIS data

Naturalearthdata.com (public domain) is a collection of GIS data within the following categories:

  • cultural—human and political, including borders for countries and smaller administrative divisions, as well as cities and urban areas
  • physical—coastlines, rivers, lakes, bathymetry, and geographic lines
  • raster backgrounds—Natural Earth 2 (topographic), ocean bottom, shaded relief grey

Which data should I get?

For this lesson

New users should download topographical data from ETOPO1 (1px = 1km x 1km). Please download a grid-registered, georeferenced tiff in either Ice Surface or Bedrock and unzip it into your Data_ETOPO1 folder.

In general

Outdated due to the new http://demex.cr.usgs.gov techology.

For maps needing a topographical base, confirmed mapmakers will prefer to use the SRTM3 for its better quality. However, process is a bit more complex than downloading a single file. You will need to:

  1. Know the coordinates of the area you want to map—although you do have the option of visually selecting the area on the download page.
  2. Find the associated GIS files (also called tiles). SRTM files have names such as "N22E112.hgt.zip", standing for 22⁰ North, 112⁰ East.
  3. Download them. A small island will be made of a few files, the Korean peninsula of about a hundred, and Eurasia of more than 5,000.
  4. Unzip them.
  5. Load them into QGis.

For maps needing features such as national borders, cities, rivers, etc., data sets from Natural Earth provide a range of options in various levels of detail. They are simple to select and work with, so both beginner and confirmed mapmakers will find them useful to download.

Step 3: Load a GIS file into QGis as a layer

1. Add Vector Layer, 2. Add Raster Layer, 3. Remove Layer(s)

Loading a GIS file adds the data into your project as a layer. For our purposes, we care about vector layers and raster layers. There are three ways you can add layers into your project: using the menu, using the keyboard shortcuts, or using the toolbar icons.

  • Using the menu: go to Layer > Add Vector Layer... or Layer > Add Raster Layer..., depending on which you would like to add, and Layer > Remove Layer(s) to delete.
  • Using the shortcuts: Ctrl + Shift + V (Cmd + Shift + V on Mac) to add a vector layer or Ctrl + Shift + R (Cmd + Shift + R) to add a raster layer, and Ctrl + D (Cmd + D) to remove layer(s).
  • Using the toolbar: Simply click the icon corresponding to the layer type you want to add.

You can also remove a layer by selecting it in the Layers window, right clicking on it, and clicking on Remove.

Since the ETOPO1 data is a raster file, go ahead and add it to your project using whichever Add Raster Layer method you prefer.

Step 4: Add some custom colors

Main page : Wikipedia:Graphic Lab/Resources/QGis mapcolor files - for more colormap files

The topographic GIS data you downloaded is by default displayed using a monochromatic palette (mapcolors) going from white to black; however, you have the option of using other colors. You can either load an existing mapcolor file, edit an existing mapcolor file or create your own mapcolors. To do this, you will need to edit the layer's properties.

Please note that per the Wikipedia map conventions, you should use the colors provided for all topographical shading.

Loading mapcolors

For this, you will be using the Wikicarto_2.0.qml file you created earlier in this tutorial.

  1. Right click on the layer name in the Layers window and select Properties. The Layer Properties window will pop up.
  2. Under the Symbology tab, click Load Style ... at the bottom of the window.
  3. Find and select Wikicarto_2.0.qml, then hit Open.
  4. Click OK. Your map should now be in color!

Editing mapcolors

The Colormap tab with colors already loaded.

If you would like to edit already loaded mapcolors, simply go to the Colormap tab. There, you can add or delete entries by selecting them and clicking the appropriate buttons. You can also edit the Value, Color, and Label fields of any entry by simply double clicking on the field you wish to change. Click Apply to see the changes.

Creating mapcolors

If you would like to create your own colors from scratch—this is advised against for topographical maps, which should follow the map conventions—you can do so by following these steps on a layer which has not had colors loaded onto it:

  1. Access the Layer Properties.
  2. Under the Symbology tab, change Single band properties > Color map from Grayscale to Colormap. This will enable the options in the Colormap tab.
  3. In the Colormap tab, use the Add entry button to add colors. They will all have default values.
  4. Double click on the Value, Color, or Label fields of the entries to change them. For topography, the Value will be the altitude (ex.: 100 for 100m, 250 for 250m, and so on).
  5. Apply or OK to see the changes.

Saving mapcolors

You can save edited or created mapcolors as a style file by clicking Save Style... at the bottom of the Layer Properties window. This will allow you to apply those mapcolors to another map. If you would like to make colors—whether loaded or created—the default colors for the map, click Save As Default. This will allow you to keep editing or loading different colors while having the option to Restore Default Style if you don't like the changes you've made.

Existing color palettes

The QGis mapcolor files page already has some palettes you can use. Simply copy-paste the code into a text document, then save as PALETTENAME.qml and follow the steps above to load it into your map.

Step 5: Output your map, aka using the Print composer

What we want is this: a high quality topographic output. With QGis and experience, you can get this in about 5 to 10 minutes.

You are now working with QGis, your GIS data—namely, ETOPO1—and your customized palette. To output your first topographic background, don't use File > Save as Image, which is a simple screenshot. For better quality, use the Print composer. This step will walk you through outputting a map like the one you see on the right, including a grid and an inset that lets the viewer know where in the world this section is located.

Background
  1. To give a smooth, gradient-like appearance to the colors, go to Layer > Properties > Colormap > Color interpolation (at the top), and set it to Linear.
  2. By default, the canvas of QGIS (geographic area visible in QGis) will become the area of interest for print composer.
  3. Open the Print composer: QGIS (1.7)> File > New Print Composer (Ctrl + P).

Placing the main section for output

In the print composer:

  1. On the right, under General, you can change the Size and Orientation of the image you will be outputting. A larger paper size and dpi means a higher quality, but don't go overboard! You don't want to end up with a huge file size that takes forever to upload and download.
  2. To add your map, you can either go to Layout > Add Map or click the Add new map icon in the toolbar.
  3. Click and drag in a diagonal motion across the white area to place your map. You can move it around and resize it once it's placed.

Adding a grid

  1. Make sure the placed map is selected—you will see four squares in the corners of the image when it is.
  2. On the right, go to the Item tab.
  3. Click on Grid and check the Show grid? option.
  4. Increase the Interval X and Interval Y fields. You can play around with the Offset X and Offset Y options, as well as the Grid type and Line color, until you get a grid you like. You can also turn on and change options for the border annotations.

Adding a localizer inset

 In progress

  1. step
  2. step
  3. step

Go to File > Export as Image or PDF or SVG (warning, SVG export is somewhat dodgy) and you have yourself a high quality topographic background!

Visual step-by-step

 In progress

Links

The table above has links to various tutorials and resources which can help in the creation of Wikipedia maps from digital georeferenced data (GIS).