A tutorial to perform basic operations with spatial data in R, such as importing and exporting data (both vectorial and raster), plotting, analysing and making maps. R is great not only for doing statistics, but also for many other tasks, including GIS analysis and working with spatial data. For instance, R is capable of doing wonderful maps such as this or this. In this tutorial I will show some basic GIS functionality in R. There are many other useful packages, e.g. check CRAN Spatial Task View. Some of them will be used below. Let’s create an example dataset: retrieve occurrence data for the laurel tree (Laurus nobilis) from the Global Biodiversity Information Facility (GBIF) So we have got a simple dataframe containing spatial coordinates. Let’s make these data explicitly spatial Important: define geographical projection. Consult the appropriate PROJ.4 description here: http://www.spatialreference.org/ Use readShapePoly to read polygon shapefiles, and readShapeLines to read polylines. See also shapefile in raster package. spTransform (package sp) will do the projection as long as the original and new projection are correctly specified. The original coordinates are in lat lon format. Let’s define the new desired projection: Lambert Azimuthal Equal Area in this case (look up parameters at http://spatialreference.org) The getData function from the dismo package will easily retrieve climate data, elevation, administrative boundaries, etc. Check also the excellent rWBclimate package by rOpenSci with additional functionality. Easy! The raster function reads many different formats, including Arc ASCII grids or netcdf files (see raster help). And values are stored on disk instead of memory! (useful for large rasters) A raster stack is collection of many raster layers with the same projection, spatial extent and resolution. Let’s collect several raster files from disk and read them as a single raster stack: A rasterbrick is similar to a raster stack (i.e. multiple layers with the same extent and resolution), but all the data must be stored in a single file on disk. http://cran.r-project.org/web/packages/raster/vignettes/Raster.pdf http://cran.r-project.org/web/packages/dismo/vignettes/sdm.pdf http://cran.r-project.org/web/packages/sp/vignettes/sp.pdf Source.