The data and code required for these examples can be dowloaded here.

This site contains live versions of the examples discussed in the paper An introduction to software tools, data and services for geospatial analysis of stroke services

The live examples can be accessed via the navigation bar above. There are several implementations of two examples:

  1. A choropleth, or thematic map, displaying per-postcode estimates of stroke cases.

  2. An example of estimating catchment zones for rehabilitation centers, and the resulting load on centers, based on distances through the road network.

The examples are illustrated using both R and Python.

A more advanced version of the second example, that uses web services requiring API keys, is also provided. Interested readers must create the relevant accounts and install the necessary keys in order to explore this example fully.

Getting started with R and Python

For convenience, the supplementary material from the paper, providing some general instructions for getting started, is available here

The Software Carpentries are an excellent source of training material for readers getting started with R and Python.

Running the R examples locally

Running the examples requires internet access for installing packages, geocoding and other web services.

  1. Fetch the source code and data using the link at the top of this page.

    Recreating the examples requires a local installation of R and/or Python and copies of the source code.

  2. The Choropleth example for R is in Choropleth/mmc_surrounds.Rmd and Choropleth/mmc_surrounds.R.

    Open Choropleth/mmc_surrounds.Rmd from within Rstudio, select Session->Set Working Directory->To Source File Location

    Press the Knit icon.

  3. The Catchment Zones example of R is in RehabCatchment/README.Rmd.

    Open RehabCatchment/README.Rmd from within Rstudio, select Session->Set Working Directory->To Source File Location

    Press the Knit icon.

    This example takes considerable time to run. Some results are saved after the first run so that subsequent runs are faster.

    It is useful to click the “open in browser” button to view the resulting document so that the forward and back buttons can be used to navigate the interactive maps.

  4. Problems

    The two most likely common problems are an incorrectly set working directory for R and incompatible package versions.
    The working directory can be determined by examining the line at the top of the Console window in Rstudio.

    When working with one of the examples the working directory should be set, using Session->Set Working Directory,
    to the example folder, such as Choropleth.

    Package version incompatibilities may be problem if you are already using R and have some of the required packages
    installed. The early parts of the examples attempt to install missing packages, and the dependencies,
    but won’t upgrade packages that are already installed. If you experience problems, attempt to explicitly install packages as follows:

    install.packages(c("tidyverse", "sf", "here", "units", "tmaptools", 
                       "tmap", "knitr", "mapdeck", "googleway",
                       "mapview", "devtools", "dodgr", "viridisLite"))
    
    devtools::install_github("HughParsonage/PSMA")

    If problems persist, attempt to update the packages using

    update.packages(ask = FALSE)
  5. Please use the github issue tracker to ask questions or point out problems.

  6. The code does depend on column names and content of data tables provided in the zip file. These structures may differ if you download the data yourself or adapt the code to alternative data sets. Modifying the examples is definitely possible with experience and practice.

Running the Python examples locally

  1. Fetch the source code and data using the link at the top of the page.
  2. Follow the Python setup instructions here.

The Choropleth example for Python is in python/notebooks/example1.pynb.

The Catchment Zones example of Python is in python/notebooks/example1.pynb.