Tag Archives: GIS

Convert 16bit to 8bit GeoTiff

Note to self: use the following command to scale 16 bit spatial raster data down to 8 bit.

gdal_translate -a_nodata 0 -of GTiff -ot Byte -scale 0 65535 0 255 input.tif 8bit_output.tif

Tagged , , , ,

QGIS Processing crash

I’ve been looking at setting up some graphical models in QGIS recently using the tools available through the Processing option. I ran into some issues on my installation of QGIS 2.2 / Processing 2.0 on Ubuntu 12.04.4 64bit that I wasn’t able to recreate using the OSGeo4W install on Windows 7 Home Premium 64bit.

The problem was that I could build the models fine, but when I added in an output file for the model, the application crashed. Doing a bit of hunting around, this seems to be a known issue (see http://hub.qgis.org/issues/8716). It looks like a related bug report has been moved to a priority of ‘Blocker’ (http://hub.qgis.org/issues/6785).

So the way round the crash is to save your model with no name entered in the output field, then right click on the algorithm box and select edit (rather than double clicking to open that dialog). Add in the name of your output and save the model again. It should then all work as built.

Tagged ,

LiDAR processing

sudo apt-get install liblas-bin

Install the liblas library and you are good to go in terms of understanding what you have in your .las file.

A .las file is a standard binary format file containing LiDAR instrument data. LiDAR data provides a source of high-quality and very dense topographic data which is usually/often represented as an unstructured point cloud. The points will have an X, Y, Z coordinate to allow them to be placed in 3D space but can have much more information associated to them, such as return intensity, point classification and the return number. From this information it is possible to infer facts about the target being observed, such as whether it is vegetation and what the density of the vegetative canopy might be. The last return (or if there is only a single return) is usually taken to be the ground surface (or the roof of a building).

liblas provides access to some useful command line utilities:

1) lasinfo

lasinfo options:
  -h [ --help ]         produce help message
  -i [ --input ] arg    input LAS file
  -v [ --verbose ]      Verbose message output
  --no-vlrs             Don't show VLRs
  --no-schema           Don't show schema
  --no-check            Don't scan points
  --xml                 Output as XML
  -p [ --point ] arg    Display a point with a given id.

2) las2txt

las2txt options:
  -h [ --help ]         produce help message
  -i [ --input ] arg    input LAS file.
  -o [ --output ] arg   output text file.  Use 'stdout' if you want it written
                        to the standard output stream
  --parse arg           The '--parse txyz' flag specifies how to format each
                        each line of the ASCII file. For example, 'txyzia'
                        means that the first number of each line should be the
                        gpstime, the next three numbers should be the x, y, and
                        z coordinate, the next number should be the intensity
                        and the next number should be the scan angle.

                         The supported entries are:
                           x - x coordinate as a double
                           y - y coordinate as a double
                           z - z coordinate as a double
                           X - x coordinate as unscaled integer
                           Y - y coordinate as unscaled integer
                           Z - z coordinate as unscaled integer
                           a - scan angle
                           i - intensity
                           n - number of returns for given pulse
                           r - number of this return
                           c - classification number
                           C - classification name
                           u - user data
                           p - point source ID
                           e - edge of flight line
                           d - direction of scan flag
                           R - red channel of RGB color
                           G - green channel of RGB color
                           B - blue channel of RGB color
                           M - vertex index number

  --precision arg       The number of decimal places to use for x,y,z,[t]
                         --precision 7 7 3
                         --precision 3 3 4 6
                        If you don't specify any precision, las2txt uses the
                        implicit values defined by the header's scale value
                        (and a precision of 8 is used for any time values.)
  --delimiter arg       The character to use for delimiting fields in the
                         --delimiter ","
                         --delimiter ""
                         --delimiter " "
  --labels              Print row of header labels
  --header              Print header information
  -v [ --verbose ]      Verbose message output
  --xml                 Output as XML -- no formatting given by --parse is
                        respected in this case.
  --stdout              Output data to stdout

3) las2ogr

las2ogr options:
    -h print this message
    -i <infile>     input ASPRS LAS file
    -o <outfile>    output file
    -f <format>     OGR format for output file
    -formats        list supported OGR formats

Together these tools can help get the information contained in a las file into a GIS ready format to then be taken into a desktop software package such as SAGA or QGIS. Interpolation of the Z parameter for the relevant return number will then create an elevation model that can be used in subsequent analyses.

More information can be found here:  http://www.liblas.org/utilities/index.html

Tagged , ,

Geoserver install

So that I remember, should I ever need to do this again:

1) download the binary files from the geoserver website – geoserver.org/display/GEOS/Latest You want the ones that are labeled Binary (OS independent)

2) unzip the file (in this case version 2.4, RC1)

unzip geoserver-2.4-RC1-bin.zip

3) change directory into the binary directory of the unzipped file

cd geoserver-2.4-RC1/bin

4) run the startup script


5) if there is a Java error then chech which version you have installed using

which java

if nothing is installed then use

sudo apt-get-install openjdk-7-jdk

check where it is installed using the ‘which’ command again and then set the JAVA_HOME variable

export JAVA_HOME=/usr

exit the terminal and start a new one. Navigate back to the bin directory of the geoserver extracted file

6) run geoserver


7) When the command line output halts and you see ‘Started SelectChannelConnection’ then goto a local browser and type


choose the second option to start the geoserver admin panel and login with the default details user=admin, passwd=geoserver

Tagged , ,

otb on Mint 14

OK – I had otb set up to run through the SEXTANTE plugin in qgis usingthe standard repository as mentioned in the online help:

sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable

Then there was an upgrade of the otb libraries and everything stopped working – not good. I don’t know if what I have done as a work around is a sensible thing to do but it seems to have gotten my installation up and running again:

  • Uninstall the SEXTANTE plugin
  • Uninstall qgis and anything else installed using the ubuntugis-unstable repository
  • Install the stable repository – sudo apt-add-repository ppa:ubuntugis/ubuntugis
  • Run sudo apt-get update
  • Then use sudo apt-get install libotb otb-bin otb-bin-qt python-otb to install the libraries and applications
  • Reinstall the SEXTANTE plugin and hopefully it will all work

That worked for me but I don’t know what will happen when qgis 2.x is released.

Tagged ,