Posts Tagged ‘ GDAL ’

Accessing ESRI File Geodatabases on Arch Linux

First up, download the File Geodatabase API from here.  You’ll need create an ESRI Global account and agree to the API’s EULA.  Once the API’s tarball is downloaded, extract it and keep track of where you put it.  Next up, download GDAL’s PKGBUILD, a patch, and changelog from here.  All three files need to be in the same directory.  Next, edit the PKGBUILD to look for the API.  Personally I put the API in /opt so I added:


and then ran mkgpkg.  Once GDAL finished compiling pacman -U upgraded gdal.  Now I can go into QGIS, click Add Vector, click the Directory radio button, and select File GDB in the file type drop down.  Easy peasy.

Watch your projections when using QGIS’s raster clipper

I needed to clip a county-wide Mr. Sid file down to just the area of interest for a project.  QGIS‘s raster clipper tool, a front end for gdal_translate, made that easy.  You can either clip by a selected extent, or by a masking polygon from a vector layer.  I did run into one problem, the project’s CRS was the local State Plane projection and the source raster was in UTM.  Gdal_translate returned the following error:

Computed -srcwin falls outside raster size of 28249x42326

Resetting QGIS’s project CRS to match the raster’s projection fixed the error.

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!

GDAL 1.9 hits community-testing

GDAL 1.9.0 has hit Arch’s community-testing repository.  Hopefully Geos 3.3.2 won’t be far behind.  It’s important that both are up to date before PostGIS 2.0’s release is official.