Friday, 17 February 2012

QGIS/GRASS Tutorial - Vectorising Surface Heights of between 28 and 53 metres from lidar.

There are advantages for using raster data over vector, any 'continuous' varying coverage is far better displayed as a raster or (pixel grid). The height data I'm using is low resolution lidar. One advantage of converting from raster to vector is that you can add columns to your data attribute table for further analysis at a later date. You can do some of this analysis with the GRASS Module (r.mapcalc) if you wish to stay with raster data.

Step 1.      Open the GRASS Mapset which contains your lidar (raster) grid data (as above).

Step 2.      Load your small area of data onto the QGIS canvas (above).

Step 3.      In the GRASS Module List search for '', 'INPUT' file = 'testascii', 'OUTPUT' file = 'testascii_vectorised'. I've always found it useful to name the output files with some indicator to which module or description was used to produce it.

Step 4.      When we open the attribute table there is a new 'value' field containing the height values     which we can now query. On the bottom right of the attribute table click 'Advanced Search' (below) using the query: value >= '28' AND value <= '53' then click 'Test' to verify the query structure works. The Search has found 2178 matching features, Click 'OK' (search results) and 'OK' again on the query builder.

Step 5.      We can now see the results highlighted in amber.

Step 6.      We will now add some attribute geometry for extra analysis and create a separate new shapefile 'Height_between_28&53m_withGeomCols.shp'. Note the two extra columns with 'AREA' and 'PERIMETER' which can be used for further analysis later on.

Step 7.      Next... we can style the the layer using the 'value' field with the following settings. We use the 'Equal Interval' Mode and three classes should suffice.

Step 8.      The result should look something like this. Below I've added a backdrop map tile and a transparent value of 50% to the height data shapefile to give the data some context.


Wednesday, 15 February 2012

GDALWARP - How to import a large number of Arcinfo Ascii Grid files into Grass GIS

I  recently downloaded around a 1000 Arcinfo Ascii Grid files and wanted to import them into Grass GIS. My first thoughts were to use the '' module wxGUI (of course) but this wouldn't allow me to import all the files in one go. Then i tried the '' module but again this only seemed to want one file at a time. Thanks to Markus Neteler for this solution...The 'GDALWARP' utility!.

Step 1. In the command line navigate to the folder containing your '*.asc' files. 

Step 2. Type the following: gdalwarp --config GDAL_CACHEMAX 8000 -wm 8000 *.asc mosaic.tif

The processing of each file should follow this format on the command line as above. Job Done. An image entitled 'mosaic.tif' will have been created in the same directory.

Step 3. Simply import the 'mosaic.tif' into Grass GIS. Apply your own colour table as necessary.