Archive for July, 2012

Use QGIS to generate contour lines from a DEM

This guide will help those who have used ESRI software in the past to create countour line datasets.  Instead of spending big bucks on ArcDesktop and the Spatial Analyst you can do this for free with QGIS.

The first step is to load your DEM data.  QGIS uses GDAL to handle raster datasets, and GDAL can load almost every format out there.  Seriously, GDAL is awesome.  Once you have loaded your data make sure it is in the correct projection by right clicking the layer in the table of contents, the select Set Layer CRS.  You’ll also want to set the project to your layer’s CRS, you can either use the Set Project to Layer CRS in the same menu, or go to File, Project Properties, and click the Coordinate Reference System tab.

In other GIS software your DEM may automatically be drawn with a grayscale or colormap already set.  In QGIS by default you’ll only see a gray rectangle.

DEM Loaded

QGIS displaying a DEM with no colormap or grayscale stretching.

On the style tab of the layer properties menu you can select how you want your raster to be symbolized.  Here’s the same layer displayed with elevations represented by pseudocolors:

QGIS pseudocolors

DEM displayed with pseudocolors

To generate contours click Raster, then Extraction, then select the Contour menu.

QGIS Contour menu

QGIS contour menu.

The menu is pretty self explanatory.  It is a front end for the gdal_contour command line tool.  You can use the generated command at the bottom as the starting point for a batch file if you have several files you need to convert.

DEM with contours

Contour lines sitting on DEM they were created from

Easy peasy!

Slight problem using pacman to upgrade glibc to 2.16.0

The newest version of glibc hit Arch’s core repository today.  The packagers have changed where the libraries are installed from /lib to /usr/lib.  Now /lib is a symlink to /usr/lib, but to make this change the old /lib has to be deleted.  This archwiki page walks you through how to smoothly perform the upgrade.  DON’T USE pacman -Syu –force!  Using –force in this case will SERIOUSLY bork your system.  If you are getting an error like:

error: failed to commit transaction (conflicting files)
glibc: /lib exists in filesystem
Errors occurred, no packages were upgraded.

just follow the steps on the wiki page to resolve them.

I followed the steps in the guide but still had some files in /lib not owned by glibc so I couldn’t  upgrade.  It turned out to be a few directories worth of old kernel modules so I deleted them manually and re-ran pacman -Su and the upgrade went smoothly from there.

Weird

This blog hit 1776 views on July 4th.  Cool.