Custom search

Samstag, 20. Dezember 2014

Hierarchical image segmentation

Ingredients are a colored infrared image (CIR), GRASS GIS and some of its features (i.segment, i.segment.hierarchical, g.gui.mapswipe,) and a tricky landscape with heterogeneous geomorphology and heterogeneous forest stands with various combinations of spruce (Picea abies), fir (Abies alba), pine (Pinus sylvestris), beech (Fagus sylvatica), ash (Fraxinus excelsior) and maple (Acer pseudoplatanus).

Image segmentation or object recognition is the process of grouping similar pixels into unique segments, also refered to as objects.

GRASS GIS features:
  • i.segment (manual, src) identifies segments (objects) from imagery data.
  • i.segment.hierarchical (manual, src) performs a hierarchical segmentation on imagery data by using i.segment.
  • g.gui.mapswipe (manual) compares interactively two maps by swiping a visibility bar.
The resolution of the CIR is 0,2m:
g.region -p                                                                    
projection: 99 (Transverse Mercator)
zone:       0
datum:      hermannskogel
ellipsoid:  bessel
north:      252452
south:      251798.6
west:       -112476.2
east:       -111678.2
nsres:      0.2
ewres:      0.2
rows:       3267
cols:       3990
cells:      13035330
colored infrared image (CIR)
Important options of i.segment are:
  • minsize = Minimum number of cells in a segment.
  • threshold = Difference threshold between 0 and 1; 0 merges only identical segments; threshold = 1 merges all.
Let's do 2 runs of i.segment.hierarchical
i.segment.hierarchical group=cirgroup thresholds=0.02,0.05,0.1,0.15,0.2,0.25,0.3,0.35 output=cirsegmin10 outputs_prefix=segmin10__%.2f minsizes=10 memory=1000 iterations=20 processes=4                                                        
i.segment.hierarchical group=cirgroup thresholds=0.02,0.05,0.1,0.15,0.2,0.25,0.3,0.35 output=cirsegmin20 outputs_prefix=segmin20__%.2f minsizes=20 memory=1000 iterations=20 processes=4

and load some results with different thresholds and minsizes to g.gui.mapswipe:

scene 1:

threshold=0.2 minsize=10
threshold=0.2 minsize20

threshold=0.3 minsize20

threshold=0.3 minsize=10
threshold=0.35 minsize=10
threshold=0.35 minsize20

scene 2:

threshold=0.2 minsize=10
threshold=0.2 minsize20  

threshold=0.3 minsize=10
threshold=0.3 minsize20

threshold=0.35 minsize=10
threshold=0.35 minsize20

scene 3:
threshold=0.2 minsize=10

threshold=0.2 minsize20

threshold=0.3 minsize=10
threshold=0.3 minsize20

threshold=0.35 minsize=10   
threshold=0.35 minsize20

Nice open source tools for image segmentation! Have also a look at the Orfeo Toolbox!

Mittwoch, 19. November 2014

Joint effort needed for biodiversity

Open data and open source software may be a guide for such an joint effort. Let's have a look on the data side at ressources of EEA, GBIF and Natural Earth, on the software side at QGIS and R.

GBIF facilitates free and open access to biodiversity data, e.g. species distribution data. This kind of data can be accessed and processed by R and its packages dismo, sp, rgdal and maptools.

# load libraries
# download species distribution data as spatial points data frame, e.g. Myricaria germanica
myrger <- gbif("Myricaria", "germanica", geo = TRUE, sp = TRUE, removeZeros = TRUE)

# visualize data for a quick check
plot(wrld_simpl, col = "light yellow", axes = T)
points(myrger$lon, myrger$lat, col = "red", cex = 0.5)
text(-140, -50, "Myricaria\ngermanica")
GBIF species distribution data of Myricaria germanica (accessed: 2014-11-18)
# define projection of the spatial data
proj4string(myrger) <- "+proj=longlat +datum=WGS84"

# export to shape file to use it in QGIS
writeOGR(myrger3, dsn = ".", driver= "ESRI Shapefile", layer = "gbif_mg_ll")
Natural Earth has a nice compilation of cultural, physical and raster GIS data; in this example the boundaries of countries are used. The European Environment Agency (EEA) delivers data of the biogeographical regions and the article 17 report GIS data on the conservation status of habitat types and species for the reporting period 2001-2006 required by the Habitat directive. The European Topic Centre on Biological Diversity supplies data of the article 17 report for the period 2007-2012.

Let's collect all the GIS data for e.g. habitat type "3230 Alpine rivers and their ligneous vegetation with Myricaria germanica" and load the data into QGIS. Data for France and Slovenia of the reporting period 2007-2012 isn't available yet.

Data: countries - Natural Earth; biogeographical regions and article 17 period 2001-2006 - EEA;
article 17 period 2007-2012 - European Topic Centre on Biodiversity
And zoom into several European mountain regions:


Scandinavian mountains

Scandinavian mountains quite in the North
A closer look to Austria


and a recent article about the actual and historic distribution of Myricaria germanica in Austria (Stapfia 99; see also here)

taken from Kudrnovsky & Stöhr, 2013. Myricaria germanica (L.) Desv. historisch und aktuell in Österreich: ein dramatischer Rückgang einer Indikatorart von europäischem Interesse. STAPFIA 99 (2013): 13–34.
As differences in the state of knowledge and differences in important datasets like GBIF and article 17 report are getting obvious, a joint effort of knowlegde transfer and boosted data exchange may be needed to achieve the targets of the EU Biodiversity Strategy to 2020.

Montag, 10. November 2014

Open river

As posted in earlier blogs here and here, the federal state of Tyrol provides a nice set of open data. Let's have a closer look at the river system spatial data and in particular the river Isel.

river system of Tyrol

glacier river Isel in the Eastern district of Tyrol
 The river Isel is known as one of the last near natural glacier rivers in the Alps.

In this post following open software tools are used: GRASS GIS and R. In the last days I've uploaded a new GRASS GIS addon: v.fixed.segmentpoints.

v.fixed.segmentpoints GUI

This little addon creates segment points along a vector line with fixed distances.

segment points along a vector line with fixed distances (e.g. every 10m a point along a river)
But how can this addon now be useful related to streams? One of the individual characteristics of a single stream is the long profile. The long profile shows how a river’s gradient changes as it flows from its source to its mouth/outlet.

Let's do a few simple steps in GRASS GIS:
# set every 10m a point along the vector line of the river isel (open data)
v.fixed.segmentpoints vector=riverisel cat=1 dir=C:\tmp\ distance=10

# given a 10m x 10m DEM,(open data), v.what.rast - uploads raster values at positions of vector points to the table.
v.what.rast map=segmentpoints raster=dem column=elevation

# db.out.ogr - exports attribute tables into a CSV file as input for a R session
db.out.ogr input=segmentpoints dsn=C:\tmp\rinput.csv
Then start a R session:
# import GRASS exported data into R
riverdata <- read.csv("rinput.csv", header = TRUE, sep = ",", dec = ".")

# quick look at the statistics
    distance               elevation    
 Min.   :    0           Min.   : 665.3 
 1st Qu.:14715     1st Qu.: 742.7 
 Median :29430   Median : 933.6 
 Mean   :29430    Mean   :1098.0 
 3rd Qu.:44145   3rd Qu.:1289.3 
 Max.   :58858    Max.   :2411.5 

# make data coloumns available for calculation

# plot the river long profile
plot(distance,elevation, type = "l", col = "blue", \
main = "river long profile: glacier river Isel", \
xlab = "distance from source (m)", ylab = "elevation (m a.s.l.)")
Thanks to 2 open data sets, 2 open source software and a few command line statements a river long profile can be compiled:

river long profile: Isel

 And now some impressions how the glacier river Isel evolves and transforms from its source to its outlet along its profile.

Donnerstag, 6. November 2014

Open Data and free and open source software for geographic information systems (FOSSGIS) – a tool for (voluntary) nature conservation?

Open data stored in databases accessible via the internet can be viewed and processed by free and open available geographic information systems. This article shows examples where this kind of data ca be accessed and how it can be used for nature conservation.

Article in ANLiegen Natur 36/1 (2014): 103-107.

Montag, 26. Mai 2014

northerness, easterness and slope - some proxies if a cell is "sunny"

In (plant) ecology the importance of solar radiation has been recognized for a long time.

Northerness, easterness and slope may be some of the simpler proxies for solar radiation which can be calculated by GIS.

As aspect is a circular land-surface parameter, a sine (eastness) or cosine (northness) transformation can be used to obtain a continuous gradient, stressing the north-south or east-west gradient.

In the northern hemisphere for instance, slopes facing south receive more potential insolation than those facing north; a relation between northerness and slope can also be established.

Let's do some calculations with

Open Data


Open Source

The commands are as simple as

# build a VRT from a list of datasets
gdalbuildvrt -input_file_list dem_tiles.txt dem.vrt

# r.external - Links GDAL supported raster data as a pseudo GRASS raster map
r.external input=C:\data\dem.vrt output=dem10m

# calculation of northerness, easterness and the interaction between northerness and slope
r.northerness.easterness --verbose elevation=dem10m

 The result maps of r.northerness.easterness are
  • northerness: cos(aspect)
  • easterness: sin(aspect)
  • interaction between northerness and slope: northerness*slope
DEM 10m x 10m

DEM 10m x 10m (zoomed)

easterness (zoomed)

northerness (zoomed)

northerness*slope (zoomed)
 Let's do some checks in the field.