Section 3 Quick tour of giscourse R functions

3.1 Introduction

The giscourse package contains some quickly typed functions based on the material in the introduction to open source gis course. The package implements a few examples in the course as R functions.

link to package documentation

The package saves typing out all the lines of code needed to produce some useful maps and allows the functions to be re-run quickly for different sites.

However, these are all high level functions, with preset defaults. They may not do exactly what you want. In this case you can edit and adapt the functions by applying the concepts that are explained throughout the course. The functions are aimed mainly at simplifying the task of setting up an R GIS environment with some commonly used data layers.

3.2 Quick map

The simplest way to form a web map is just to type qmap() into the console, or into a code chunk within a markdown document. This will map the bounding box of Bournemouth as a default area. If you type some other text as the input then the function will attempt to geocode the text and zoom to the appropriate place.

library(giscourse)
qmap()

Notice that the map can be taken full screen and contains a geocoding serach control. You can use that to test a search for another place name that could be used as the focus for a map.

As you move the mouse over the map you will see the latitude and longitude of the point shown at the top. This is very useful if you want to focus on a point that does not have name. Write down the longitude and latitude for use in a query.

3.3 Adding a WMS

The local geoserver can be used to visualise some layers in WMS format. These layers are only for visualisation and cannot be analysed directly. However WMS layers can be zoomed to any extent without putting strain on the system.

qmap("Arne, Dorset") %>% uk_wms()

3.4 WMS with query

The geoserver has been set up with sql queries on the priority habitat and landcover layers. So if two key words are provided to the hab_wms() function two wms layers will be added to the quick map.

qmap() %>% hab_wms(hab="calc",bhab="Grass")

3.5 Deforestation mapping

The package provides quick access to Hansen’s analysis of global deforestation.

https://earthenginepartners.appspot.com/science-2013-global-forest

The raw data can be clipped to a site for analysis. The WMS layer provide a visual representation of the raster layer..

qmap("Sumatra") %>% hansen_wms()

3.6 Capturing a polygon or set of points

The package has a function for quickly digitising some geometries from within an interactive R sesssion. Type emap into the console. The results are saved in the database and also returned as an object.

conn<-connect()
#mp<-emap()
st_read(conn,"emap") %>% mapview()
disconnect()
#> [1] TRUE

3.7 More examples from the package

Check the second vignette in the package documentation for more examples.

link to package documentation