Geospatial data is becoming increasingly used to solve numerous ‘real-life’ problems (check

out some examples here).

In turn, R is becoming a powerful, open-source solution to handle this type of data, currently providing

an exceptional range of functions and tools for GIS and Remote Sensing data analysis.

In particular, **raster data** provides support for representing spatial phenomena

by diving the surface into a grid (or matrix) composed of cells of regular size. Each raster

dataset has a certain number of columns and rows and each cell contains a value with information

for the variable of interest. Stored data can be either: (i) Thematic – representing a

**discrete** variable (e.g., land cover classification map) or (ii) **continuous** (e.g., elevation).

The `raster` package currently provides an extensive set of functions to create, read, export,

manipulate and process raster data sets. It also provides low-level functionalities for creating

more advanced processing chains, as well as the ability to manage large data sets. For more

information, see: `vignette("functions", package = "raster")`

.

Answers to the exercises are available here.

You can also check more about raster data on the tutorial series about this topic here.

Start by downloading, uncompressing, and loading the sample data for these exercises from this

link (digital elevation model data from SRTM-v4.1 for the Peneda-Geres National Park, Portugal).

The data is in GeoTIFF format with file name: *srtm_pnpg.tif*.

**Exercise 1**

Check out the size of the data in terms of number of rows, columns, cells and layers.

**Exercise 2**

Check the spatial resolution of the raster and its coordinate reference system (CRS).

**Exercise 3**

Get the raster extent object and calculate the ‘height’ (in the y-axis) and the length (in x-axis) of the raster.

**Exercise 4**

Calculate the mean and standard-deviation for all pixels.

**Exercise 5**

Calculate the 1%, 25%, 50%, 75% and 99% quantiles for all pixels.

**Exercise 6**

Using a QQ-plot, investigate deviations from normality in the distribution of elevation values.

**Exercise 7**

Extract raster values for 100 randomly generated points within the image (use `set.seed(12345)`

) for obtaining the same values as in the solutions).

**Exercise 8**

Convert the elevation units of the DEM from meters to feet. Make a RasterStack object with both the rasters with meters (original) and feet (new).

**Exercise 9**

Crop the raster to the following extent: Upper-left {ymax = 4654705, xmin = 554615}, and, Lower-right {ymin = 4618355, xmax = 589015}.

**Exercise 10**

Re-project the sample raster to Datum ETRS 1989 (European Terrestrial Reference System 1989), projection Lambert Azimuthal Equal Area (LAEA) and change the resolution to 100m with the bi-linear method.

## Leave a Reply