High Quality Maps With R and ggplot

Slides:



Advertisements
Similar presentations
B2PDF b2pdf is the new and innovative release of our powerful command line tool for PDF customization b2pdf is a robust stand alone PDF file generation.
Advertisements

Get Started with GIS Mapping Part 2 of 3 Madhu Lakshmanan.
Get Started with GIS Mapping Part 1of 3 Madhu Lakshmanan.
What are Geographical Information Systems (GIS) & ArcView GIS software? What is a Geographical Information System (GIS)? Introduction to ESRI ArcView 3.x.
UK Spatial Data into SQL Server 2008/r2 + Reporting Services Daniel Gaze & Neal Atkinson The Co-operative Group
Geographic tools and resources
Greater London Authority - Intelligence Unit. The Mayor’s responsibilities transport policing housing planning and development culture economic development.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
Introduction to the Digital BAS 1. Overview What is the MAF/TIGER Database? What is included in the Digital BAS package? What is the difference between.
GIS Level 2 MIT GIS Services
©2007 Austin Troy Lecture 8: Introduction to GIS 1.Multi-layer vector query operations in Arc GIS 2.Vector Spatial Joining Lecture by Austin Troy, University.
Poster Print Size: This poster template is 20” high by 24” wide. It can be used to print any poster with a 3:4 aspect ratio. Placeholders: The various.
Classifier Decision Tree A decision tree classifies data by predicting the label for each record. The first element of the tree is the root node, representing.
IURC Digital Mapping Update Electric Utilities Task Force April 6, 2004.
Geographic Information Systems
ArcView and GMT – An Introduction to Two Simple GIS Systems Bill Langin EAS 781 9/18/02.
Poster Print Size: This poster template is 36” high by 36” wide. It can be used to print any poster with a 1:1 aspect ratio. Placeholders: The various.
Carol Blackwood – Geo User Support Vivienne Mayo – User Support Digimap Roam webinar 12 th November 2014.
IBIS GIS Mapping Missouri “Show and Tell”. Outline 1.What is KML 2.Why we chose KML 3.Show and Tell.
Introduction to the Use of Geographic Information Systems in Public Health Elio Spinello, MPH California State University, Northridge.
@ 2007 Austin Troy. Geoprocessing Introduction to GIS Geoprocessing is the processing of geographic information. Perform spatial analysis and modeling.
RGS-IBG Online CPD course in GIS Analysing Data using WebGIS: The Office of National Statistics Session 3.
Get started with PivotTable reports Make your data work for you Imagine an Excel worksheet of sales figures. It lays out thousands of rows of data about.
Merging census aggregate statistics with postal code-based microdata Laine Ruus University of Toronto. Data Library Service ,
Poster Print Size: This poster template is 24” high by 36” wide. It can be used to print any poster with a 2:3 aspect ratio including 36x54 and 48x72.
Chapter 3 Working with Symbols and Interactivity.
Overview Dennis L. Johnson What is GIS? Geographic Information System Geographic implies of or pertaining to the surface of the earth Information implies.
Preparing Data for Analysis and Analyzing Spatial Data/ Geoprocessing Class 11 GISG 110.
In this presentation we will elaborate more on the importance of Choropleth Maps, Group Layers, Scales, Attribute Classification, Definition Queries, Hyperlinks,
Creating Web based Thematic Maps using Open Source Platforms 2009 Ohio GIS Conference September 16-18, 2009 Crowne Plaza North Hotel Columbus, Ohio 2009.
Poster Print Size: This poster template is 21” high by 45” wide and is printed at 200% for a 42” high by 90” wide poster. It can be used to print any poster.
Techniques in body paint Adam Crowther. For this tutorial, I will be using my “Savage Hoplite” model. We start by simply pulling up the model in Lightwave.
CONCOCTING A GIS Designing a Geodatabase Optimized for Data Maintenance and Map Production Jim Isbell | Engineering Tech. II | Kern County Assessor’s Office.
Best Practices for Designing Effective Map Services Tanu Hoque.
5 Marzo 2007 Census mapping and Gis Part II: dissemination Fabio Crescenzi Istat, Central Directorate on General Censuses UNECE Training Workshop on Census.
Preparing and Deploying Data to ArcPad Juan Luera.
Poster Print Size: This poster template is 36” high by 48” wide. It can be used to print any poster with a 3:4 aspect ratio. Placeholders: The various.
1106: Geographical Information: a primer Communicating with Cartography 29/10/2004.
GIS 1 GIS Lecture 4 Geodatabases Copyright – Kristen S. Kurland, Carnegie Mellon University.
ราชภัฏสุราษฎร์ธานีวิจัย ครั้งที่ 11
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
Poster Print Size: This poster template is 44” high by 44” wide. It can be used to print any poster with a 1:1 aspect ratio. Placeholders: The various.
AMB HW LOW LEVEL SIMULATION VS HW OUTPUT G. Volpi, INFN Pisa.
Unit 42 : Spreadsheet Modelling
Structural analysis of the aggregate outputs from the 2011 Census to develop alternative integrated multidimensional conceptual models of data and geographies.
REPLACE THIS BOX WITH YOUR ORGANIZATION’S
Using the AccuGlobe Software with the IndianaMap Using the AccuGlobe Software.
Build a database V: Create forms for a new Access database Overview: A window into your data So far in this series of courses, you’ve built tables, relationships,
Advanced Spatial Methods in R
Ggplot2 A cool way for creating plots in R Maria Novosolov.
Esri UC 2014 | Demo Theater | Batch Geocoding Online Bruce
José Aponte Public Health Advisor Module 7: Mapping 12 June 2012 Epi Info™ 7 Introductory Training Office of Surveillance, Epidemiology, and Laboratory.
Department of Geography, University College London, 1-19 Torrington Place, London WC1E 6BT, UK web Methods.
Introduction to Geographic Information Systems Fall 2013 (INF 385T-28620) Dr. David Arctur Research Fellow, Adjunct Faculty University of Texas at Austin.
Template Provided By Genigraphics –
Mapping London. Software examples MapInfo Arc GIS- Same functionality as MapInfo Instant Atlas MapQuest and others Improve data visualization Enhance.
Poster Print Size: This poster template is 36” high by 48” wide. It can be used to print a Tri-Fold poster with 12” wings. Placeholders: The various elements.
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
Medway: Here we David Whiting SEPHIG, 16 June, 2016.
Physical Structure of GDB
ggplot2 Merrill Rudd TAs: Brooke Davis and Megsie Siple
Touring Data with Power Map
PowerPoint Day 1 Credibility Builder
Preliminaries: -- vector, raster, shapefiles, feature classes.
Charts, Graphs, and Diagrams
Vector Geoprocessing.
Survey Results Respondents: 39 of 51 – 76%
Presentation transcript:

High Quality Maps With R and ggplot Simon Hailstone

What am I here to Talk About? Where to get data to map Where to get shapefiles How to geocode the easy way How to combine all of this in ggplot Pros and Cons

Why Use R for Maps? Business Objects Reporting System  Limited charting capabilities and no maps! R can be used to run through chunks of data and generate image files R can dynamically name the files it creates Business Objects can then concatenate hyperlinks together

The Benchmark http://flowingdata.com/2009/11/12/how-to-make-a-us-county-thematic-map-using-free-tools/

The Benchmark http://www.thisisthegreenroom.com/2009/choropleths-in-r/

Data Sources

Find Something Interesting Lots of statistics in the UK are released with a geographic dimension Plenty of examples over at data.london.gov.uk/datastore and also at the Office of National Statistics (ONS) Look for the terms MSOA and LSOA! This allows really easy matching of data to UK geography

LSOA and MSOA We are very lucky in the UK to have the ONS who maintain geographic sub-divisions of the country The whole country is split into census output areas. These are then aggregated to form larger areas such as wards and regions. LSOA and MSOA are common geographic areas for which statistics are released

LSOA and MSOA

Find Something Interesting Ambulance Service Incidents from London datastore website LSOA level dataset for a couple of interesting domains Binge Drinking Assault Deprivation Population Also identified A&E departments and sizes to plot as reference points: http://www.england.nhs.uk/statistics

Shapefiles

What is a shapefile? Widely used file type for saving geographical features Vector based: Point Polyline Polygon

Where Can I get Shapefiles? Once again, ONS to the rescue: geoportal.statistics.gov.uk

Where Can I get Shapefiles? Ordnance Survey: http://www.ordnancesurvey.co.uk/business-and-government/products/opendata-products.html

Where Can I get Shapefiles? Natural Earth: naturalearthdata.com

Where Can I get Shapefiles? Open Streetmap: openstreetmap.org

How do I get Shapefiles into R? The maptools package provides the function readShapeSpatial which allows easy importing of shapefiles: readShapeSpatial("London_CCG.shp", IDvar="PCO12NM") If your shapefiles are really complex try simplifying them using gSimplify in the rgeos package. Simplifying shapefiles can give bad results so consider filtering to the bare minimum first!

Geocoding

Geocoding the Easy Way! Geocoding is the act of adding geographic information to data. In most cases this involves using postcodes to attach co-ordinates This can be a bit of a pain Large postcode tables (2.5 million records) Inconsistent postcode formats in different systems Maintenance: Need to keep postcode tables up to date I don’t have postcodes for the A&E departments!

Geocoding the Easy Way! Luckily R (with a little help from Google) makes it easy if you only have a small amount of data to geocode! library("ggmap") AAE$Address <- paste0(AAE$Name,",LONDON,UK") geocode(AAE$Address)

Geocoding the Easy Way!

GGPLOT

Pulling things Together in GGPLOT Before you can use a shapefile with ggplot, the fortify command needs to be used: fortify(msoa,region="MSOA04CD") This converts a shapefile to a dataframe This can be quite time consuming keep the number of features as low as possible simplify if it still takes a long time.

Pulling things Together in GGPLOT ggplot works using layers which allows fine tuned control of a lot of graphical features Shapefile polygons can be coloured based on data Because of ggplot’s layering abilities, additional layers can be added: CCG borders A&E departments

Pulling things Together in GGPLOT geom_polygon function is used to plot shapefiles coord_map is used to set the projection of the map (mercator was used in this instance theme_bw was used to minimise additional graphical elements. Those remaining were removed using ggplot’s theme options: theme( legend.position="bottom", legend.title=element_blank(), legend.key = element_rect(linetype= 0), axis.text=element_blank(), axis.title=element_blank(), axis.ticks=element_blank(), panel.border=element_blank(), panel.grid=element_blank() )

Improving Output QUality Important to use strokes in ggplot. Shapes surrounded by a stroke line give a far superior graphical finish. The Cairo package is also used to improve graphical output with anti-aliasing: ggsave(file="Population.png", plot=p, width=200, height=200, units="mm", type ="cairo-png")

Output Quality Default output!

Output Quality With Cairo package:

Output Quality With Cairo package and strokes added

Final Output: Population

Final Output: Deprivation

Final Output: Assaults

Final Output: Binge Drinking

Pros & Cons

Pros & Cons Pros Cons The ususal! Re-usable  Automation Shareable Transparent code Flexible Precise control Really nice output images! Cons Labels and text formatting in general Processing time  Not as fast as specialised GIS packages Although much of the processing only needs to be done as a one off Not as user friendly for single bits of analysis  QGIS still wins here

Questions