Monthly Archives: November 2012

Extracting lines ending with specific character using sed or grep

A quick note (to myself mostly) about how to extract lines from a text file that end with a specific set of characters. In Linux, you can very easily do this using ‘grep’ or ‘sed’. But, first a little bit of background. Continue reading

Multivariate Environmental Similarity Surfaces (MESS) index in GRASS GIS

The Multivariate Environmental Similarity Surfaces (MESS) is an index that represents how similar a point in space is to a reference set of points, with respect to a set of predictor variables (Elith et al 2010). The function was first implemented as part of the Maxent software package, and is also available in the dismo package for R (see also here and here).

The latter works well on small and medium sized data sets. However, they take a long time to run on larger data sets, e.g., when working with 1km² raster grids covering eastern Africa. I therefore wrote a small R script to compute MESS in GRASS GIS. Continue reading

Converting an ArcMap layer file into an SLD document

Most open source GIS programs can open all most common, and quite a few obscure data format (thanks to the gdal library). What they can’t open is the ArcMap layer files (.lyr).  A layer file defines the symbology used to draw the data when it is added to the display and stores information about the symbology, symbology classifications, labeling properties, scale dependency and definition. So what if a data layer is distributed with a layer file?
Continue reading

Reading GRASS GIS vector attribute tables into R

Linking GRASS GIS and R will give you a very powerful set of geo-spatial analytical tools. The spgrass6 offers a very convenient interface between GRASS GIS and R. You can read more about this package in Bivand, R. 2007. Using the R-GRASS interface. OSGeo Journal 1, 36-38.

Read the whole vector layer
It allows you amongst others to easily import vector data layers from GRASS GIS into R using the function readVECT6(). This will import the whole vector layer. But what if you you only need to import the attribute table? Importing the whole vector layer would give unnecessarily overhead and would take (much) longer to import. Continue reading

Opening MODIS tiles in QGIS

NASA offers a very convenient web-based tool to select and download the tiles you need; Reverb / ECHO.  The tiles are in HDF format and use the Sinusoidal grid tiling system (proj4 definition: +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs). But you probably want to have the data in another data format and in another projection. NASA offers a very convenient cross-platform tool to reproject and convert the data (it also makes it very easy to mosaic tiles): the Modis Reprojection Tool (MRT).

But something I didn’t know is that it is also possible to open the tiles directly in QGIS. Continue reading