# Fourier transforms for multitemporal analysis

Fourier transforms for detecting multitemporal landscape fragmentation by remote sensing GRASS GIS and R code used in:

Rocchini, D., Metz, M., Ricotta, C., Landa, M., Frigeri, A., Neteler, M. (2013). Fourier transforms for detecting multitemporal landscape fragmentation by remote sensing. International Journal of Remote Sensing, 34: 8907-8916. (DOI) (IF: 1.138)

GRASS GIS: Fourier transform calculation

```# Setting the region of interest based on a Landsat image
g.region rast=lsat7_2002_10 -p
```

Performing PCA on a multitemporal set of images (Landsat images in this case)

1987

```i.pca input=lsat5_1987_10,lsat5_1987_20,lsat5_1987_30,lsat5_1987_40,lsat5_1987_50,lsat5_1987_70 \
output=lsat5_1987_pca
```

2002

```i.pca input=lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40,lsat7_2002_50,lsat7_2002_70 \
output=lsat7_2002_pca
```

Showing the first principal component

1987

```d.mon x0
d.rast lsat5_1987_pca.1
```

2002

```d.mon x1
d.rast lsat7_2002_pca.1
```

Fourier transform

1987

```i.fft input=lsat5_1987_pca.1 real=lsat5_1987_pca1.real imaginary=lsat5_1987_pca1.imag
```

2002

```i.fft input=lsat7_2002_pca.1 real=lsat7_2002_pca1.real imaginary=lsat7_2002_pca1.imag
```

Creating Fig. 2 in Rocchini et al. (2013)

1987

```d.mon x2
d.rast lsat5_1987_pca1.real
```

2002

```d.mon x3
d.rast lsat7_2002_pca1.real
```

Additional example with MODIS data: Fig. 6 in Rocchini et al. (2013)

Import data: image covering a temporal period from 2005-02-02 to 2005-03-05 (band 2 being used)

```r.in.gdal input=Goodes.EUAS.2005033.band2.tif output=Goodes.EUAS.2005033.band2
```

Import data: image covering a temporal period from 2005-07-12 to 2005-08-12 (band 2 being used)

```r.in.gdal input=Goodes.EUAS.2005193.band2.tif output=Goodes.EUAS.2005193.band2
```

Fourier transforms

```i.fft input=Goodes.EUAS.2005033.band2 real=Goodes.EUAS.2005033.band2.real imaginary=Goodes.EUAS.2005033.band2.imag
```
```i.fft input=Goodes.EUAS.2005193.band2 real=Goodes.EUAS.2005193.band2.real imaginary=Goodes.EUAS.2005193.band2.imag
```

R: statistical analysis

Importing the Fourier image from GRASS GIS by the spgrass6 library

```library(spgrass6)
cat=c(F,F), ignore.stderr=TRUE, plugin=NULL)
```

where lsat5_1987_pca1.real and lsat7_2002_pca1.real are the Fourier transform images derived from GRASS GIS

Kernel Density Plot: Fig. 4 in Rocchini et al. (2013)

```library(sm)
sm.density(fft.images\$lsat5_1987_pca1.real, lty=1, lwd=2, ann=T,
xlim=c(0,255), ylim=c(0,0.013), xlab='Fourier transform value', col='blue', cex.label=4)
par(new=T)
sm.density(fft.images\$lsat7_2002_pca1.real,lty=1, lwd=2, ann=F,
xlim=c(0,255), ylim=c(0,0.013), xlab=' ', col='red', cex.label=4)
legend(110, 0.012, c('Density function 1987', 'Density function 2002'),
fill = c('blue', 'red'), cex=1.2, box.lty=0)
```

Hexagon binning: Fig. 5 in Rocchini et al. (2013)

```library(hexbin)
hbin <- hexbin(fft.images\$lsat5_1987_pca1.real, fft.images\$lsat7_2002_pca1.real, xbins = 50)
plot.bin<-plot(hbin, style = 'nested.lattice', legend=F,
xlab='Fourier transform value 1987', ylab='Fourier transform value 2002')
hexVP.abline(plot.bin\$plot.vp, 0, 1)
```