Getting Started

One of the issues with GIS is that many of the files we will be working with are quite large. Fortunately, in recent years, UCL has seriously beefed up the storage available for students. You now get 100GB of free storage, which should be plenty for the work you will be doing this year! The Bartlett faculty has several gigabytes of storage space available on their central servers, so before we get started, we will connect to our N drive to carry out all of our practical work over the coming weeks.

In your N drive: drive, create a new folder called GIS and within this a subfolder called wk1

Wlecome to the world of GIS

Spatial analysis can yield fascinating insights into geographical relationships. However, at times it can be difficult to work with. You will get lots of error messages and have software crash. The academic staff are here to help you work through these practicals but we do not know everything. It’s a good idea to become familar with online sources of help, such as:

1 The Basics of Geographic Information

There are two main types of data which are used in GIS applications to represent the real world. Vectors – Points, Lines and Polygons and Rasters – Grids of cells with individual values.

Real world Raster Vector

In the above example the features in the real world (e.g. lake, forest, marsh and grassland) have been represented by points, lines and polygons (vector) or discrete grid cells (raster) or a certain size (e.g. 1 x 1m) specifying land cover type.

We will look into these in more detail in future lectures, but in this course, most of the data we will be dealing with will be vector data, although raster data will feature in later weeks.

1.1 Important GIS data formats

There are a number of commonly used geographic data formats that you will come across during this course and it’s important to understand what they are, how they represent data and how you can use them.

1.1.1 GeoJSON

GeoJSON (Geospatial Data Interchange format for JavaScript Object Notation). See: http://geojson.org/ is becoming an increasingly popular spatial data format, particularly for web-based mapping as it is based on JavaScript Object Notation.

1.1.2 Shapefiles

Perhaps the most commonly used GIS data format is the Shapefile. Shapefiles were developed by ESRI (http://www.esri.com/) – one of the first and now certainly the largest commercial GIS company in the world. Despite being developed by a commercial company, they are an open format and Shapefiles can be used (read and written) by a host of GIS Software applications.

A shapefile is actually a collection of files – at least three of which are needed for the shapefile to be displayed by GIS software. They are:

  1. .shp - the main part of the file which contains the feature geometry (e.g. image below).
  2. .shx - an index file which stores the position of the feature IDs in the .shp file
  3. .dbf - the part of the file that stores all of the attribute information associated with the coordinates – this might be the name of the shape or some other information associated with the feature – note how in a shapefile attribute data are held in a separate file whereas in a GeoJSON the attributes and boundaries are all contained in the same file.
  4. .prj - the part of the file which contains all of the coordinate system information (the location of the shape on Earth’s surface). Data can be displayed without a projection, but the .prj file allows software to display the data correctly where data with different projections might be being used. Again, in file formats like GeoJSON, this information is contained all in the same file.

1.1.3 GeoJSON and Shapefiles

We’re now going to explore GeoJSON and shapefiles in action. Go to: http://geojson.io/#map=16/51.5247/-0.1339

  1. Using the drawing tools to the right of the map window, create 3 objects: a point, line and a polygon as I have done above. Click on your polygon and colour it red and colour your point green.
  2. Using the ‘Save’ option at the top of the map, save two copies of your new data – one in GeoJSON format and one in shp format.
  3. Open your two newly saved files in a text editor such as notepad or notepad++. For the shapefile you might have to unzip the folder then open each file individually. What do you notice about the similarities or differences between the two ways that the data are encoded?

1.1.4 Raster data

Most raster data is now provided in GeoTIFF (.tiff) format, which stands for Geostarionary Earth Orbit Tagged Image File. The GeoTIFF data type was created NASA and is a standard public domain format. All necesary inforamtion to establish the location of the data on Earth’s surface is embedded into the image. This includes: map projection, coordinate system, ellipsoid and datum type.

1.1.5 Other types of data

Aforementioned data types and formats are likely to be the ones you predominately encounter. However there are several more used within spatial analysis. Theres include:

Vector

Raster

  • Band SeQuential (BSQ) - technically a method for encoding data but commonly refered to as BSQ.
  • Hierarchical Data Format (HDF)
  • Arc Grid

There are normally valid reasons for storing data in one of these other formats. For example, BSQ are just data with a seperate text header file (.hdr) providing geographic spatial reference information. Earth observation data often monitors the electromagenitc spectrum in bands. Humans see in the visible range of the spectrum and our vision is composed of red, green and blue wavelengths. If we wanted to analyse just the red wavelength the BSQ format would let us ‘read in’ only that data. In comaprsion a GeoTIFF might come with all the data ‘packaged’ in one file and when doing analysis over thousands of images would significantly slow things down. That said you can now often find GeoTIFFs seperated in a similar format to BSQ and it’s fairly straightforward to convert between raster formats. Often the most successful projects and reports will combine numerous datasets from various sources (and formats) to glean new insights.

1.1.6 Geodatabases

A geodatabase is a collection of geographic data held within a database. Geodatabases were developed by ESRI to overcome some of the limitations of shapefiles. They come in two main types: Personal (upto 1 TB) and File (limited to 250 - 500 MB), with Personal Geodatabases storing everything in a Microsoft Access database (.mdb) file and File Geodatabases offering more flexibility, storing everything as a series of folders in a file system. In the example below we can see that the FCC_Geodatabase (left hand pane) holds multiple points, lines, polygons, tables and raster layers in the contents tab.

1.1.7 GeoPackages

A GeoPackage is an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial data. A GeoPackage stores multiple spatial data layers (vector and raster) as a single file. One of the major advantages of a GeoPackage is the ability to analyse geographic data in SQLite producing code based, reproducible and transparent workflows. A GeoPackage is an SQLite database, a widely used relational database management system and as it stores data in a single file it is very easy to share, copy or move.

1.1.8 SpatiaLite

SpatialLite is an open source library that extends SQLite core. Support is fairly limited and most software that supports SpatiaLite also supports GeoPackage as they both build upon SQLite. It doesn’t have any clear advantage over GeoPackage, however it is unable to support raster data.

1.1.9 PostGIS

PostGIS is an opensource database extender for PostrgeSQL. Essentially PostgreSQL is a database and PostGIS is an add on which permits spatial functions. The advantage of using PostGIS over GeoPackages is that it allows users to access the data at the same time, can handle large data more efficiently and reduces processing time. In this example (https://medium.com/@GispoLearning/learn-spatial-sql-and-master-geopackage-with-qgis-3-16b1e17f0291) calcualting the number of bars per neighbourhood in Leon, Mexico the processing time reduced from 1.443 seconds (SQLite) to 0.08 seconds in PostGIS. However, data stored in PostGIS is much harder to share, move or copy.

1.1.10 What will I use

The variety of data types and formats can see a bit overwhelming. But don’t worry, most of the time you’ll be using shapefiles, GeoPackages or raster data. You just need to be aware of the all the different types so that later on in the course if someone is talking about PostGIS data you are aware that it is a type of spatial data.

2 Data

The volume of geographic information which is freely available for use in the UK is increasing exponentially, and spatially referenced data can often be found in many different places. In this practical we’re going to use data from the London data store - a free and open data-sharing portal provided by the Greater London Authrotiy (GLA), also known as City Hall that is the devovled regional governance body of London.

We are going to get spatial data of the London boroughs and join fly tip data that is provided as a .csv file. .csv stands for comma-separated values (CSV) - it uses a comma to separate each value.

At the end of this document I’ll also run through some common sources of data that will stand you in good stead for the rest of the course.

2.1 Data download

Firstly we need to get the outline of the london boroughs. The geographic boundaries that are used in the UK are a complex, often inter-related, but ever changing mass of areas. For anyone new to the UK (or indeed not a trained quantitative geographer), it can be quite a daunting task to attempt to understand all of the boundaries that are in use. Fortunately the Office for National Statistics has an online beginners guide to UK geography. If you need more information on the vast array of different UK geographies, this is the place to start: http://geoportal.statistics.gov.uk/datasets/a-beginners-guide-to-uk-geography-2018-v1-0

  • Spatial Data
  1. To get the data go to: https://data.london.gov.uk/

  2. Seach for Statistical GIS Boundary Files for London

  3. Download the statistical-gis-boundaries-london.zip

  4. Unzip the data and save it to your week 1 folder.

  • CSV data
  1. On the same website search for fly tipping incidents

  2. Download the .csv file

2.2 Data pre-processing

Question Open the .csv in Excel, what do you notice about how the data is stored?

Answer The year is a column and for each area the values are repeated for different years. In our analysis it is easier to have the different years as a field row and populated for each area. By this I mean, we want to go from this…

To this…

There are many ways to do this, as we are going to use this dataset in Arc Map, QGIS and R I’ve done it in Excel using a pivot table.

  1. Go to Insert > PivotTable.

  2. Select the original table and create a PivotTable in a new worksheet.

  3. The PivotTable Field box will appear, experiment with the different fields in each of the areas.

I’ve used the following:

Note how I’ve altered the total_action_taken to the sum of… as the original was displaying incorrectly, to do so:

  1. Click on drop down button for total_action_taken > Value Field Settings > select Count.

It’s important to think about what data we actually need in the next step, it’s good practice to avoid data redundancy where possible. The spatial data we have downloaded containts borough name and we will link based on code.

Now save the Excel sheet that contains the pivot table as a new .csv. Make sure that the first row of data holds the coloumn titles. Remove all empty rows.

When saving the file also avoid any special characters (e.g. -) and spaces, use an underscore instead of spaces.

2.3 Data loading

Now it’s time to load, inspect and do some basic manipulation of this data. As mentioned in the lecture there are several GIS software ‘types’, here we will repeat the same process across Arc GIS, QGIS and R. Each system has specific benefits, but in general there has been a recent shift towards the use of QGIS and R, both being opensource. Arc GIS was the first major spatial analysis software produced by the Environmental Systems Research Institute, Inc. (Esri), founded in 1969 by Jack Dangermond. Due to its high cost and lack of customisation it is now less commonly used within the research community.

2.4 Arc GIS

2.4.1 Basics

ArcGIS should be installed as a standard programme in the UCL desktop and you should be able to navigate to it from the Windows start button.

2.4.1.1 Installing ArcGIS on your own computer

As a UCL student, you can install ArcGIS on your own computer. This is easy if you have a PC, but if you have a Mac this can be trickier as Arc will only run in a PC environment. If you have a Mac, the options open to you are either to:

  1. Run ArcGIS through the application - http://www.ucl.ac.uk/isd/services/computers/remote-access/desktop
  2. Duel boot your machine using bootcamp, install Windows (7 or 8 is fine) and then install Arc onto the Windows partition.
  3. Install some kind of virtualisation software such as Parallels (http://www.parallels.com/ca/products/desktop/) or VMware (http://www.vmware.com/products/fusion/), and run Arc on a virtual windows machine

If you can, it is preferable to run Arc on Bootcamp as virtualisation software can be slow. The facility should suffice for this course, however. ArcGIS (Version 10.6 is the latest at time of writing, but may have already been superseded) can be downloaded from the UCL Software Database for free - https://swdb.ucl.ac.uk/.

2.4.1.2 Getting Help

ArcGIS is a huge and complex piece of software, but thankfully is has an excellent help system – depending on the version you are using (they are all quite similar anyway) you can access the online help system here:

http://resources.arcgis.com/en/help/main/10.2/

http://resources.arcgis.com/en/help/main/10.1/

2.4.1.3 ArcGIS

ArcGIS is actually a whole suite of software built and maintained by ESRI - http://www.esri.com/software/arcgis - and is perhaps the most widely used price of GIS Software in the world. Other software such as MapInfo and QGIS (which is open source and free to run) work in similar ways, so if you understand Arc, you will be able to pick up these other pieces of software very quickly. Within the ArcGIS for Desktop suite you will find the following programmes:

  • ArcCatalog - Similar to Windows Explorer, ArcCatalog allows you to manage your GIS files, folders and geodatabases

  • ArcGIS Administrator - This programme us used to manage licences for the various elements of ArcGIS

  • ArcGlobe - ArcGlobe allows you to view and analyse your data in 3D – this interface looks very similar to Google Earth and is part of the 3D analyst extension

  • ArcMap - This is the programme you will use most often – it is the main mapping and spatial analysis element of ArcGIS

  • ArcScene - ArcScene is a 3D viewer which allows you to navigate and interact with your 3D raster and feature data

ArcCatalog and ArcMap are in bold as these are the only programmes we will be using explicitly in this course. By all means experiment with the others if you have any spare time!

2.4.2 ArcCatalog

  • Find and run the ArcCatalog piece of software

  • Once ArcCatalog Opens, go to File > Connect To Folder… and navigate to the N:folder, right click in the contents area and create a new Flie Geodatabase.

You can import data layers into a Geodatabase within ArCatalog, however we will do this in ArcMap.

2.4.3 ArcMap

ArcMap is the core of the ArcGIS suite and where you would normally produce maps, carry out spatial analysis functions and automate processes. Find ArcMap in your start menu and run the programme. When the programme starts, you should see something similar to the image below. ArcMap has various elements to the graphical user interface, but here some of the key buttons are highlighted:

  1. Search for and open ArcMap
  2. Upon opening select the database you just created in the dialogue box

  1. Click ok
  2. It’s important to now set the map document up properly. Go File > Map Document Properties, enter the details you wish. You can see the connection to the Geodatabase we just made. Click store relative pathnames, this means as long as the data stays in the same position relative to the path then Arc Map can load all the layers. For example if you moved your work from the C: drive to an external drive, H:.
  3. Using the Plus icon (add data layer) navigate to the extracted folder you saved earlier.
  4. Open London_Borough_Excluding_MHW.shp, but feel free to explore the other data layers. In the left hand Table Of Contents you can unselect layers to turn them off or drag layers above or below to change the display order. In the example below the wards layer is showing above the borough layer.

Note, while we have loaded the shapefile, it is not stored in our Geodatabase yet.

Useful tips

  • To the right of the document you will see the Catalog and Search tabs.The Catalog tab is a small version of ArcCatalog and will let you see what data is stored in the current Geodatabase. The search tab will let you find any analysis tool within ArcGIS. Try searching for Clip.

  • If you right click on the boroughs layer you will see various options. Zoom to layer is very useful if you ever get lost in your ArcMap document.

  1. Now right click on the borough layer and open the attribute table. You’ll see the GSS_CODE field, which is the same code we output in our .csv. If you now right click on a field you’ll also be able to see the data type (e.g. string, integer). For example:

We’re now going to join our fly tipping data to the lonon borough shapefile. So:

  1. Right click on the london borough layer > Joins and Relates > Join
  2. Select the GSS_CODE as the field in the layer to base the join on
  3. Navigate to the .csv we created earlier
  4. Select the code field that matches (in my case this is called Row Labels)
  5. Select only to join matching records
  6. Validate join and click OK.

You will get errors, ArcGIS does not like fields starting with numbers (e.g. 2012), dashes (e.g. -) or spaces.

  1. The join should work, so reopen the attribute table for the layer london boroughs.

Note, the join we have made is not permanent. To do so we need to export the layer.

  1. Right click on the london boroughs layer > Data > Export Data.
  2. The location should default to our GeoDatabase. Be sure to change the filename - again avoid all of the characters (e.g. spaces and -) previously mentioned. Add the data layer to the map.

Now lets use the data we’ve joined to create a basic thematic map.

  1. Right click on the new london borough layer > properties.
  2. Under the symbology tab select graduated colors.
  3. Select the Value as one of the years of data we joined and change the classificaiton to something of your choice.

You should have something that looks like this:

We haven’t talked about the spatial reference of our map document

A spatial reference is a series of paramters that define the coordinate system. Within GIS we use geographic or projected cooridnate systems. The former uses a three-dimesional spherical surface to define locations of earth, whereas the latter is defined on a flat, two-dimesional surface giving it constat lengths, angles and areas.

In ArcMap we can specify what cooridate system we want to use by:

  1. Right clicking on the map document > Data Frame Properties

You’ll see that it is already set to Projected Coordinate Systems, National Grids, Europe, British National Grid. This is because ArcMap will default to the cooridnate system of the first data layer loaded.

Save your ArcMap document. We’re now going to replicate this task in QGIS.

2.5 QGIS

QGIS is very similar to ArcMap except that as it is open source and free there are many add on packages that (or plugins) that add functionality to the software.

To get QGIS on your own machine go to: https://qgis.org/en/site/forusers/download.html

  1. Search for and open QGIS

Navigate to your downloadrd fly tipping csv file.

Add an appropaite layer name

Under Record and Field Options select the First record has field names box

Under Geometry Definition, select No geometry (attribute only table)

Then click Add

In the bottom left of QGIS under layers you should see your csv table now loaded. If you right click on it and select open attrbiute table you can explore the data within it.

2.6 R

2.7 What will I use

3 Data sources

3.1 UK Data Service

Census Geography at Edina - https://census.edina.ac.uk/

The UK Data Service geography service (formerly known as UKBORDERS) actually provides much more than just boundaries for the geographies that are used to disseminate Census information – it has a library of hundreds of current and former boundary datasets for which attribute data are produced in the UK.

3.2 ONS

The Office for National Statistics (ONS) are the national statistical agency for England and Wales and have recently started to provide access to boundary data for the statistics they produce for various geographic areas.

Many of the boundaries on the ONS Geoportal are also available from the Edina Census Geography website in a more flexible fashion, however the ONS website provides very quick access to bulk-downloads – something which can be very useful when reading data directly from the web using computer software.

3.3 OS

The Ordnance Survey (OS) are the national mapping agency for the UK. A few years ago, they opened up a number of their data products for public use including greenspace, OS Open Map and OS Terrain.

For the full range see: https://www.ordnancesurvey.co.uk/business-and-government/products/finder.html?Licensed%20for=OpenData%20(Free)&withdrawn=on

3.4 Edina Digimap

Before the Ordnance Survey opened up much of its data for public use, academics and students in the UK could access OS data using the Edina Digimap Service – this service is still available today and provides access to a number of products in addition to those available from OS Open Data.

Perhaps the most exciting of the additional OS data products available from Digimap is OS MasterMap. MasterMap is a framework for all OS data and contains layers of data that include details of real world objects such as buildings, roads, paths, rivers, physical structures and land parcels, as well as the complete UK transport network. Whilst we still are required to go through Edina OS have recently annonced plans to make this dataset free in the near future under the new Geospatial Commission.

3.5 OSM

Open Street Map is a fantastic resource – as the name suggests, all data contained in Open Street Map are open and free for anyone to use. Much like Wikipedia, anyone can contribute content to OSM and this brings with it its own benefits (frequent updates, very large user-base) and problems (data quality and patch coverage).

It’s possible to download OSM data straight from the website, although the interface can be a little unreliable (it works better for small areas). There are, however, a number of websites that allow OSM data to be downloaded more easily and are directly linked to from the ‘Export’ option in OSM. Geofabrik (one of these websites) allows you to download frequently updated Shapefiles for various global subdivisions.