ebook img

An Introduction to R for Spatial Analysis and Mapping PDF

410 Pages·2015·14.33 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview An Introduction to R for Spatial Analysis and Mapping

For my cousin John Poile (1963‒2013) ‒ Missed by many people in many ways. CB To Mandy ‒ we didn’t break each other. AJC © Chris Brunsdon and Lex Comber 2015 First published 2015 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act, 1988, this publication may be reproduced, stored or transmitted in any form, or by any means, only with the prior permission in writing of the publishers, or in the case of reprographic reproduction, in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. Library of Congress Control Number: 2014939813 British Library Cataloguing in Publication data A catalogue record for this book is available from the British Library ISBN 978-1-4462-7294-7 ISBN 978-1-4462-7295-4 (pbk) SAGE Publications Ltd 1 Oliver’s Yard 55 City Road London EC1Y 1SP SAGE Publications Inc. 2455 Teller Road Thousand Oaks, California 91320 SAGE Publications India Pvt Ltd B 1/I 1 Mohan Cooperative Industrial Area Mathura Road New Delhi 110 044 SAGE Publications Asia-Pacific Pte Ltd 3 Church Street #10-04 Samsung Hub Singapore 049483 Editor: Robert Rojek Assistant editor: Keri Dickens Production editor: Katherine Haw Copyeditor: Richard Leigh Proofreader: Neil Dowden Marketing manager: Michael Ainsley Cover design: Francis Kenney Typeset by: C&M Digitals (P) Ltd, Chennai, India Printed and bound in Great Britain by Ashford Colour Press Ltd At SAGE we take sustainability seriously. Most of our products are printed in the UK using FSC papers and boards. When we print overseas we ensure sustainable papers are used as measured by the Egmont grading system. We undertake an annual audit to monitor our sustainability. CONTENTS About the Authors Further Resources Preface 1 INTRODUCTION 1.1 Objectives of This Book 1.2 Spatial Data Analysis in R 1.3 Chapters and Learning Arcs 1.4 The R Project for Statistical Computing 1.5 Obtaining and Running the R software 1.6 The R Interface 1.7 Other Resources and Accompanying Website References 2 DATA AND PLOTS 2.1 Introduction 2.2 The Basic Ingredients of R: Variables and Assignment 2.3 Data Types and Data Classes 2.3.1 Data types in R 2.3.2 Data classes in R 2.3.3 Self-Test questions 2.4 Plots 2.4.1 Basic plot tools 2.4.2 Plot colours 2.5 Reading, Writing, Loading and Saving Data 2.5.1 Text files 2.5.2 R data files 2.5.3 Spatial data files Answers to Self-Test Questions 3 HANDLING SPATIAL DATA IN R 3.1 Overview 3.2 Introduction: GISTools 3.2.1 Installing and loading GISTools 3.2.2 Spatial data in GISTools 3.2.3 Embellishing the map 3.2.4 Saving your map 3.3 Mapping Spatial Objects 3.3.1 Introduction 3.3.2 Data 3.3.3 Plotting options 3.3.4 Adding context 3.4 Mapping Spatial Data Attributes 3.4.1 Introduction 3.4.2 Attributes and data frames 3.4.3 Mapping polygons and attributes 3.4.4 Mapping points and attributes 3.4.5 Mapping lines and attributes 3.4.6 Mapping raster attributes 3.5 Simple Descriptive Statistical Analyses 3.5.1 Histograms and boxplots 3.5.2 Scatter plots and regressions 3.5.3 Mosaic plots 3.6 Self-Test Questions Answers to Self-Test Questions References 4 PROGRAMMING IN R 4.1 Overview 4.2 Introduction 4.3 Building Blocks for Programs 4.3.1 Conditional statements 4.3.2 Code blocks 4.3.3 Functions 4.3.4 Loops and repetition 4.3.5 Debugging 4.4 Writing Functions 4.4.1 Introduction 4.4.2 Data checking 4.4.3 More data checking 4.4.4 Loops revisited 4.4.5 Further activity 4.5 Writing Functions for Spatial Data 4.5.1 Drawing polygons in a list 4.5.2 Automatically choosing the bounding box 4.5.3 Shaded maps Answers to Self-Test Questions 5 USING R AS A GIS 5.1 Introduction 5.2 Spatial Intersection or Clip Operations 5.3 Buffers 5.4 Merging Spatial Features 5.5 Point-in-Polygon and Area Calculations 5.5.1 Point-in-polygon 5.5.2 Area calculations 5.5.3 Point and areas analysis exercise 5.6 Creating Distance Attributes 5.6.1 Distance analysis/accessibility exercise 5.7 Combining Spatial Datasets and Their Attributes 5.8 Converting between Raster and Vector 5.8.1 Raster to vector 5.8.2 Converting to sp classes 5.8.3 Vector to raster 5.9 Introduction to Raster Analysis 5.9.1 Raster data preparation 5.9.2 Raster reclassification 5.9.3 Other raster calculations Answers to Self-Test Questions References 6 POINT PATTERN ANALYSIS USING R 6.1 Introduction 6.2 What is Special about Spatial? 6.2.1 Point patterns 6.3 Techniques for Point Patterns Using R 6.3.1 Kernel density estimates 6.3.2 Kernel density estimation using R Self-Test Question 1 6.4 Further Uses of Kernel Density Estimation 6.4.1 Hexagonal binning using R 6.5 Second-Order Analysis of Point Patterns 6.5.1 Using the K-function in R 6.5.2 The L-function 6.5.3 The G-function 6.6 Looking at Marked Point Patterns 6.6.1 Cross-L-function analysis in R 6.7 Interpolation of Point Patterns with Continuous Attributes 6.7.1 Nearest neighbour interpolation 6.7.2 Inverse distance weighting 6.8 The Kriging Approach 6.8.1 A brief introduction to kriging 6.8.2 Random functions 6.8.3 Estimating the semivariogram 6.9 Concluding Remarks Answers to Self-Test Question References 7 SPATIAL ATTRIBUTE ANALYSIS WITH R 7.1 Introduction 7.2 The Pennsylvania Lung Cancer Data 7.3 A Visual Exploration of Autocorrelation 7.3.1 Neighbours and lagged mean plots 7.4 Moran’s I: An Index of Autocorrelation 7.4.1 Moran’s I in R 7.4.2 A simulation-based approach 7.5 Spatial Autoregression 7.6 Calibrating Spatial Regression Models in R 7.6.1 Models with predictors: A bivariate example 7.6.2 Further issues 7.6.3 Troubleshooting spatial regression Answer to Self-Test Question References 8 LOCALISED SPATIAL ANALYSIS

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.