One of my goals for early 2016 is to learn how to use QGIS, a freely available open source Geographic Information System.
I have been an ArcGIS user for years, and consider myself fairly proficient. If you're a student and your university has a site license for ArcGIS, you can actually get a free personal license, good for one year from the date of install. The ability to have ArcGIS installed on my personal machine, and not having to rely on remote desktop connections, really helped facilitate my research during the last couple years. I have an Apple laptop, but I found that if I allocate sufficient memory (4 GB) and hard disk space to my Windows virtual machine, I can run ArcGIS quite happily. ArcGIS is extremely powerful, but it is also prohibitively expensive for many individuals and for small organizations, and is also Windows-only at this time. I am not sure where I will end up working at this time, and I certainly cannot assume I will have access to ArcGIS when I get there. As such, I feel that it behooves me to learn alternative solutions for any GIS needs I have.
QGIS provides many of the same powerful analysis tools as ArcGIS, thanks to its integration with other open source GIS tools, such GDAL, GRASS GIS, PostGIS, and MapServer.
GDAL is a translator library for raster and vector data, allowing you to transform your data into a number of different projections (coordinate reference frames) and data formats. It can generate hillshade, compute statistics on a grid file, etc.
GRASS GIS provides a lot of the analytical, modeling, and image processing tools found in QGIS. The difference between GRASS GIS and QGIS can be confusing as GRASS GIS can be also used as a standalone GIS. Earlier versions of GRASS did not include a GUI; commands were run via a command shell and results were displayed using the X11 windowing system. QGIS interfaces directly with GRASS to provide a nice user-interface, that folks already familiar with ArcGIS might be more comfortable with. Also, to my knowledge GRASS does not integrate directly with MapServer. Early versions of QGIS did not integrate with GRASS. Those early versions of QGIS could still handle a lot of GIS needs, but it did not have a lot of the analytical tools that GRASS did.
PostGIS brings geospatial capabilities to PostgreSQL databases, allowing you to run queries and perform database operations based off geometries, locations, etc. This tool is what provides QGIS with its database capabilities.
MapServer allows for the publishing of geospatial data on the web, and provides a suite of interactive mapping tools. QGIS uses MapServer to allow you to publish your maps to web.
The most recent version of QGIS (v. 2.12) brings together these individual tools, along with a number of others, in a nicely packaged open source software that is a serious competitor to ArcGIS.
My first project:
For my first project, I decided to create a map of the Discovery Transform Fault.
To create this image:
- I brought in an ASCII Grid file (.asc) of the bathymetry data, using Layer --> Add Layer --> Add Raster Layer. This brings the grid file in as a grayscale image.
- To change the color, double-click on the layer, then go Style --> Render Type --> singleband pseudocolor. Now you can select your colormap, choose between continuous and discrete modes, create classes, and adjust your bounds just as you can in ArcGIS.
- You can create the hillshade effect by going to Raster --> Analysis --> DEM. Under mode you will find options for computing slope, aspect, hillshade, etc.
- Once your hillshade layer is created, move it down below your grid layer in the layers panel. Then, go to Layer Properties for your grid, and set a transparency so you can see the hillshade through the data.
- The plate boundary line that you see on the map was brought in as a geotiff. To make the white background transparent, you go to Layer Properties --> Transparency and set the RGB values to 255.
- Next I added the earthquake data, the purple circles that are sized by magnitude. The earthquake data was in a comma-separated file (.csv) so I went to Layers -->Add Layer --> Add Delimited Text Layer.
QGIS does a great job of reading the file and determining that the first row of data is actually the header row. I simply selected which columns represented the X field and Y field and clicked OK. It then asks you to choose a Coordinate Reference System (CRS) for the data. Select the appropriate projection, hit OK, and the data should show up on your map.
To size the points by magnitude (you can also color by attribute as well), double-click the layer to bring up Layer Properties --> Style and change Single Symbol to Graduated. Under Method, select size, and for Column, select the attribute (in my case "Mw") that you want to size by. Now you can choose what mode to break by (equal interval, natural breaks, pretty breaks, etc.).
As with any context menu, you can hit "apply" before you hit "OK" to see how the data will look before you completely exit the menu. - Now that we have all the data in QGIS, it's time to make the actual map. First, hit the New Print Composer icon (white rectangle w/ yellow asterisk) or go to Project --> New Print Composer.
- Select Layout --> Add Map, and then drag using your mouse or trackpad to draw a box where you want the map to appear. Once you let go on the mouse or trackpad, your data will pop into view. You can adjust the visible bounds of your data under Item Properties.
- Under Item Properties for the Map object, you will also find options for adding a geographic grid, or graticule, as I did above.
- The Add Scalebar and Add Legend options are tucked away under Layout. Each time you choose to add an item under Layout, you'll need to draw a box on your map so the composer knows where to place it. You can always move these items after the fact.
- If you do not want all your layers to show up in the legend, simply uncheck Auto Update under Item Properties and the select the layer you wish to remove and hit the minus icon. The icon of the pencil on the paper allows you to edit the names of the visible layers. The legend item has a "columns" option under Item Properties. This will enable you to have your layers added side-by-side, versus stacked vertically. The icon that looks like a funnel with filter the legend by map content. For my map, this meant that for certain sized earthquakes not visible in my map extents, the corresponding legend entry was removed.
- Once you have your map the way you want it, you can easily export it as an image, PDF, or SVG file.
before filtering legend for map content |
after filtering legend for map content |
One thing I noticed was that even though I used a continuous colormap for the bathymetry data, the legend shows the colorbar as discrete color blocks. It would be better show a gradual change in color from blue to red. When you first set the colorbar for the layer, the icon for the spectral colormap does show this gradation of colors, so this should be something QGIS can do. I haven't looked into this too much yet, but if I find a solution, I'll post about it.
For a lot of helpful QGIS tutorials, complete with downloadable datasets so you can easily follow along, check out www.qgistutorials.com. They start out with tutorials on basic map-making and go all the way through advanced statistical analyses of your data. It's a tremendously useful site if you really want to learn QGIS.
Thank you for the tutorial. Nice blog! I am waiting for further posts.
ReplyDelete