A (Very)Brief Introduction to QGIS, ImageJ & GDAL for processing remote sensing imagery

Alan Brown

Eurosite Remote Sensing Support Group Pages marked ‘Notes’ are my list of points to say, not slides to be shown in the presentation – but can be included in a download Three free open source software packages

Geographic Information System for viewing, editing, QGIS https://qgis.org and analysing raster and vector geospatial data

ImageJ https://imagej.net FIJI* https://fiji.sc Java-based image …OR… Image processing package processing program based on ImageJ *Fiji Is Just ImageJ

Software library for reading and writing GDAL https://gdal.org raster and vector geospatial data formats Remote sensing & GIS Remote sensing & GIS

The Remote Sensing and GIS SOURCE SNAP + Sentinel Toolboxes Software Library (RSGISLib) COMMERCIAL

QGIS

+ many more… / FREE OPEN + many more…

Raster & vector tools Image processing Statistical programming The GDAL / OGR library of vector & raster tools is open source but used in commercial packages GDAL / OGR ImageJ Notes (GIS)

• GIS – geographical information systems were developed for creating vector maps using digitising tablets, digitising on screen from air photos and collecting GPS points in the field • These maps are characteristically: • Vector data (made up of lines joining points or nodes) • Georeferenced (the nodes are co-ordinates in a reference system with a standard geographical projection) • Maps can be analysed (eg measuring areas and distances), coloured and interpreted, and transformed to different map projections and co-ordinate references without loss of information Vector, Raster, Geo-referencing A Map projection ’flattens’ the 3D earth into 2 dimensions A Coordinate reference system (CRS) then relates the 2D map to real places on the earth

WGS84 is a commonly used CRS

Graphic from QGIS training manual Slides 7 to 10 will run as short video A simple example using QGIS

Notes (New uses of GIS)

• Vector maps can be overlaid and compared eg looking at changes in the presence, length and area of features such as blocks of habitat • While GIS originally treated images as a ‘dead’ background to be digitised over, systems including QGIS can now adjust the visual appearance of the image on screen (selecting bands, changing the way the image is stretched and coloured), and stack images for visual comparison • Raster images typically have to be georeferenced in GIS, but • Changing the georeferencing (re-projection) always to some extent degrades the information content of the image Notes (QGIS)

• QGIS has many vector tools, raster tools and extension packages (plugins) • These include tools from other GIS software including GRASS GIS, SAGA GIS • These tools can also be included in Python scripts • Plugins include some powerful remote sensing toolsets eg • QGIS Semi-Automatic Classification Plugin • New free plugins are being contributed week by week Notes (Objects in GIS)

• A powerful way of using GIS to analyse images is to convert the raster data to vector objects with attributes derived from the pixel values • This is done using segmentation algorithms which automatically break the image up into groups of similar, neighbouring pixels • QGIS can overlay the objects on top of the original image, and allows thematic analysis using the tables of attributes • This reduces the scale of the data for each image from tens of millions of values (one per pixel) to hundreds or thousands of objects, allowing each object to have a large number of attributes – and allowing the GIS to stack and compare object data from many images Attribute Object March 14 2016

May 30 2016

June 2 2016

July 19 2016

Green April 8 2017 Red Near infra-red Short-wave infra-red May 8 2017

May 25 2017

= 28 bands

The segmented image has 57,130 objects but 7181 x 7236 = 519,617,16 equivalent 10 metre pixels per band

Notes (Why not use QGIS for everything?)

• A GIS environment may not be suitable because: • Your images are not geo-referenced eg • monitoring photos of flying birds, photos of habitat relevees • stereo drone images which are not ortho-corrected • (in the first case these can’t so easily be geo-referenced, in the second case the penalties of geo-referencing may be too big if you want to preserve pixel data) • You want do specialist, mainly pixel-based analysis eg • Identifying and counting objects such as birds or flower heads • Comparing stacked images when objects are very small or sub-pixel • Super-resolution image analysis (making more detailed images from repeated images of the same object) Notes (ImageJ and FIJI)

• ImageJ was developed to analyse medical images, including x-rays, 3D images from scanners and microscopic cell counts • ImageJ is fundamentally raster-based, and (in contrast to QGIS) has powerful tools for working with individual pixels, stacking and comparing hundreds or thousands of images • ImageJ can convert between image formats, colour spaces and between 8-bit, 16-bit and 32-bit images • ImageJ has a large number of open-source packages and tools known as ‘plugins’, many of which are bundled in the FIJI wrapper Slide 18 will run as a short video

Notes (GDAL)

• GDAL is a standard, shared library of raster tools (there are also related vector tools), without a GUI (graphical user interface) • You have been using this even if you are not aware of it, since these tools are already used by QGIS • It’s helpful to know how to use GDAL in a line editor or terminal, which allows you to carry out processes without the overheads of the image appearing on screen • For example, GDAL allows you to select bands from a satellite image, cut out parts of the image and replace geo-referencing data – so you can use it to pass images from ImageJ to QGIS Extract the projection and co-ordinates using ‘gdalinfo’

gdalinfo SEN2_20160314_UC.tif

AUTHORITY["EPSG","27700"]] GDAL runs in an apple Upper Left ( 167319.997, 262780.000) or windows terminal Lower Left ( 167319.997, 190420.000) Upper Right ( 239129.997, 262780.000) Lower Right ( 239129.997, 190420.000)

Select 3 bands for the RGB (red-green-blue) image gdal_translate -b 1 -b 2 -b 3 SEN2_20160314_UC.tif SEN2_20160420_UC_rgb.tif

Input to ImageJ …. Process …. Output from ImageJ gdal_translate -a_srs EPSG:27700 -a_ullr 167319.997 262780.000 239129.997 190420.000 SEN2_20160314_UC_rgb.tif SEN2_20160314_UC.tif

.. Which restores the georeferencing