Getting started with spatstat

Similar documents
Spatial point processes

No citation for this material is currently available (but will be once Jarrett Byrnes contributes the lavspatialcorrect package to the semtools

An introduction to spatial point processes

Mechanistic spatio-temporal point process models for marked point processes, with a view to forest stand data

This lab exercise will try to answer these questions using spatial statistics in a geographic information system (GIS) context.

Chapter 6 Spatial Analysis

Applied Spatial Analysis in Epidemiology

Online GIS And Spatial Metadata (Geographic Information Systems Workshop) By Terry Bossomaier;Brian A. Hope;David R. Green

Applied Spatial Analysis in Epidemiology

Testing of mark independence for marked point patterns

STATISTICAL DATA ANALYSIS AND MODELING OF SKIN DISEASES

WeatherHawk Weather Station Protocol

GIST 4302/5302: Spatial Analysis and Modeling Point Pattern Analysis

Biology 559R: Introduction to Phylogenetic Comparative Methods Topics for this week:

If you are looking for a ebook by Sergiy Butenko;Panos M. Pardalos Numerical Methods and Optimization: An Introduction (Chapman & Hall/CRC Numerical

GIST 4302/5302: Spatial Analysis and Modeling

GIST 4302/5302: Spatial Analysis and Modeling

Using the Stock Hydrology Tools in ArcGIS

GEO 6166 (Spring 2018) Advanced Quantitative Methods for Spatial Analysis OFFICE HOURS: Pre-requisites Course Description Selected Topics include

An adapted intensity estimator for linear networks with an application to modelling anti-social behaviour in an urban environment

GIS Software. Evolution of GIS Software

Introduction to Google Mapping Tools

MODULE 14: Spatial Statistics in Epidemiology and Public Health Lecture 3: Point Processes

Determination of Density 1

BAYESIAN MODEL FOR SPATIAL DEPENDANCE AND PREDICTION OF TUBERCULOSIS

Guide To Essential Math: A Review For Physics, Chemistry And Engineering Students (Complementary Science) By Sy M. Blinder READ ONLINE

Urban Canopy Tool User Guide `bo`

Cornell University CSS/NTRES 6200 Spatial Modelling and Analysis for agronomic, resources and environmental applications. Spring semester 2015

Preface. Geostatistical data

All About Spatial Data. Find it, Manage it, Use it

GIST 4302/5302: Spatial Analysis and Modeling

Arcgis Tutorial Manual READ ONLINE

ICPSR Training Program McMaster University Summer, The R Statistical Computing Environment: The Basics and Beyond

Search for the Gulf of Carpentaria in the remap search bar:

CSISS Tools and Spatial Analysis Software

Introductory Nuclear Physics By Kenneth S. Krane READ ONLINE

Data Structures & Database Queries in GIS

GEPL 4500/5500 Lab 1 Geo-rectifying Imagery Due Wednesday March 2, Geo-rectifying an image:

WHAT'S NEW IN HSC CHEMISTRY 6.0

Foundations Of Mathematical Logic (Dover Books On Mathematics) By Haskell B. Curry

Malaya J. Mat. 2(1)(2014) 35 42

Search for the Dubai in the remap search bar:

GPS Worldwide Laboratory: a community of knowledge-seekers spanning the globe

STATISTICAL COMPUTING USING R/S. John Fox McMaster University

Life Cycle of Stars. Photometry of star clusters with SalsaJ. Authors: Daniel Duggan & Sarah Roberts

Model Based Statistics in Biology. Part V. The Generalized Linear Model. Chapter 16 Introduction

School on Modelling Tools and Capacity Building in Climate and Public Health April Point Event Analysis

Utilizing Data from American FactFinder with TIGER/Line Shapefiles in ArcGIS

Photometry of Supernovae with Makali i

QUANTUM CHEMISTRY BY R.K. PRASAD DOWNLOAD EBOOK : QUANTUM CHEMISTRY BY R.K. PRASAD PDF

Search for the Dubai in the remap search bar:

Nonlinear Dynamics And Chaos By J. M. T. Thompson;H. B. Stewart

Arcmap Manual Esri 10 READ ONLINE

Session Objectives. Learn how to: Bring georeferenced aerial imagery into Civil 3D. Connect to and import GIS data using various tools and techniques.

Laboratory Exercises In Environmental Geology By Harvey Blatt

The Monte Carlo Method

APTS 2010/11: Spatial and Longitudinal Data Analysis Preliminary Material

LAB EXERCISE #3 Quantifying Point and Gradient Patterns

Applications Of Spatial Data Structures: Computer Graphics, Image Processing And Gis (Addison-Wesley Series In Computer Science) By Hanan Samet

Spatial Statistics By Brian D. Ripley

Didacticiel - Études de cas

FILE // ASHCROFT SOLID STATE PHYSICS SOLUTION MANUAL

Correspondence analysis and related methods

GIS Level 2. MIT GIS Services

Engineering Mechanics: Dynamics By J. L. Meriam

A Brief Introduction to Proofs

Visualize and interactively design weight matrices

The Golden Bough: A Study In Magic And Religion: 3rd Edition: Part VI: The Scapegoat By J G Frazer READ ONLINE

ANSWER KEY GEOGRAPHIC ISSUES OF THE 21ST CENTURY

1 Introduction to Minitab

Proteomics and Variable Selection

ST-Links. SpatialKit. Version 3.0.x. For ArcMap. ArcMap Extension for Directly Connecting to Spatial Databases. ST-Links Corporation.

Soil Mechanics Book By Gopal Ranjan

Light Microscopy In Biology: A Practical Approach (The Practical Approach Series) READ ONLINE

Moving into the information age: From records to Google Earth

CHEMISTRY 12 MCGRAW HILL RYERSON SOLUTIONS USER MANUAL EBOOK

Analysing Spatial Data in R: Why spatial data in R?

Longitudinal Data Analysis. Michael L. Berbaum Institute for Health Research and Policy University of Illinois at Chicago

WindNinja Tutorial 3: Point Initialization

module, with the exception that the vials are larger and you only use one initial population size.

SOCI 20253/GEOG 20500, SOCI 30253, MACS Introduction to Spatial Data Science SYLLABUS

Kenneth Krane Solutions Manual

THE STANDARD MODEL IN A NUTSHELL BY DAVE GOLDBERG DOWNLOAD EBOOK : THE STANDARD MODEL IN A NUTSHELL BY DAVE GOLDBERG PDF

Basic Data Analysis. Stephen Turnbull Business Administration and Public Policy Lecture 9: June 6, Abstract. Regression and R.

Arcmap Manual Esri 10 READ ONLINE

NMR SPECTROSCOPY IN INORGANIC CHEMISTRY (OXFORD CHEMISTRY PRIMERS) BY JONATHAN A. IGGO

v Prerequisite Tutorials GSSHA WMS Basics Watershed Delineation using DEMs and 2D Grid Generation Time minutes

Handbook Of Temperature Measurement Vol. 3: The Theory And Practice Of Thermoelectric Thermometry

Geographically weighted methods for examining the spatial variation in land cover accuracy

Using Microsoft Excel

let s examine pupation rates. With the conclusion of that data collection, we will go on to explore the rate at which new adults appear, a process

The Bayesian Approach to Multi-equation Econometric Model Estimation

ESTIMATING FUNCTIONS FOR INHOMOGENEOUS COX PROCESSES

Introduction to Occupancy Models. Jan 8, 2016 AEC 501 Nathan J. Hostetter

GEOGRAPHICAL INFORMATION SYSTEMS. GIS Foundation Capacity Building Course. Introduction

WindNinja Tutorial 3: Point Initialization

Quantum Mechanics: Fundamentals (Graduate Texts In Contemporary Physics) (v. 1) By Kurt Gottfried READ ONLINE

Challenge Problems Balancing Chemical Equations Answers

Hierarchical Modeling and Analysis for Spatial Data

Longitudinal Analysis. Michael L. Berbaum Institute for Health Research and Policy University of Illinois at Chicago

Transcription:

Getting started with spatstat Adrian Baddeley, Rolf Turner and Ege Rubak For spatstat version 1.54-0 Welcome to spatstat, a package in the R language for analysing spatial point patterns. This document will help you to get started with spatstat. It gives you a quick overview of spatstat, and some cookbook recipes for doing basic calculations. What kind of data does spatstat handle? Spatstat is mainly designed for analysing spatial point patterns. For example, suppose you are an ecologist studying plant seedlings. You have pegged out a 10 10 metre rectangle for your survey. Inside the rectangle you identify all the seedlings of the species you want, and record their (x, y) locations. You can plot the (x, y) locations: This is a spatial point pattern dataset. Methods for analysing this kind of data are summarised in the highly recommended book by Diggle [5] and other references in the bibliography. Alternatively the points could be locations in one dimension (such as road accidents recorded on a road network) or in three dimensions (such as cells observed in 3D microscopy). You might also have recorded additional information about each seedling, such as its height, or the number of fronds. Such information, attached to each point in the point pattern, is called a mark 1

variable. For example, here is a stand of pine trees, with each tree marked by its diameter at breast height (dbh). The circle radii represent the dbh values (not to scale). 60 40 20 You might also have recorded supplementary data, such as the terrain elevation, which might serve as explanatory variables. These data can be in any format. Spatstat does not usually provide capabilities for analysing such data in their own right, but spatstat does allow such explanatory data to be taken into account in the analysis of a spatial point pattern. Spatstat is not designed to handle point data where the(x, y) locations are fixed(e.g. temperature records from the state capital cities in Australia) or where the different (x, y) points represent the same object at different times (e.g. hourly locations of a tiger shark with a GPS tag). These are different statistical problems, for which you need different methodology. What can spatstat do? Spatstat supports a very wide range of popular techniques for statistical analysis for spatial point patterns, for example ❼ kernel estimation of density/intensity ❼ quadrat counting and clustering indices ❼ detection of clustering using Ripley s K-function ❼ spatial logistic regression ❼ model-fitting ❼ Monte Carlo tests as well as some advanced statistical techniques. 2

Spatstat is one of the largest packages available for R, containing over 1000 commands. It is the product of 15 years of software development by leading researchers in spatial statistics. How do I start using spatstat? 1. Install R on your computer Go to r-project.org and follow the installation instructions. 2. Install the spatstat package in your R system 3. Start R Start R and type install.packages("spatstat"). If that doesn t work, go to r- project.org to learn how to install Contributed Packages. 4. Type library(spatstat) to load the package. 5. Type help(spatstat) for information. How do I get my data into spatstat? Here is a cookbook example. Suppose you ve recorded the (x, y) locations of seedlings, in an Excel spreadsheet. You should also have recorded the dimensions of the survey area in which the seedlings were mapped. 1. In Excel, save the spreadsheet into a comma-separated values (CSV) file. 2. Start R 3. Read your data into R using read.csv. If your CSV file is called myfile.csv then you could type something like > mydata <- read.csv("myfile.csv") to read the data from the file and save them in an object called mydata (or whatever you want to call it). You may need to set various options to get this to work for your file format: type help(read.csv) for information. 4. Check that mydata contains the data you expect. For example, to see the first few rows of data from the spreadsheet, type > head(mydata) x y diameter height 1-1.99 0.93 1 1.7 2-1.02 0.41 1 1.7 3-4.91 1.99 1 1.6 4-4.47 1.45 5 4.1 5-4.30 0.91 3 3.1 6-3.81 0.81 4 4.3 To select a particular column of data, you can type mydata[,3] to extract the third column, or mydata$x to extract the column labelled x. 3

5. Type library(spatstat) to load the spatstat package 6. Now convert the data to a point pattern object using the spatstat command ppp. Supposethatthexandycoordinateswerestoredincolumns3and7ofthespreadsheet. Suppose that the sampling plot was a rectangle, with the x coordinates ranging from 100 to 200, and the y coordinates ranging from 10 to 90. Then you would type > mypattern <- ppp(mydata[,3], mydata[,7], c(100,200), c(10,90)) The general form is > ppp(x.coordinates, y.coordinates, x.range, y.range) Note that this only stores the seedling locations. If you have additional columns of data (such as seedling height, seedling sex, etc) these can be added as marks, later. 7. Check that the point pattern looks right by plotting it: > plot(mypattern) mypattern 8. Now you are ready to do some statistical analysis. Try the following: ❼ Basic summary of data: type > summary(mypattern) ❼ Ripley s K-function: > plot(kest(mypattern)) 4

Kest(mypattern) K(r) 0 5 10 15 20 K^iso(r) K^trans(r) K^bord(r) K pois (r) 0.0 0.5 1.0 1.5 2.0 2.5 r (metres) For more information, type help(kest) ❼ Envelopes of K-function: > plot(envelope(mypattern,kest)) envelope(mypattern, Kest) K(r) 0 5 10 15 20 K^obs(r) K theo (r) K^hi(r) K^lo(r) 0.0 0.5 1.0 1.5 2.0 2.5 r (metres) For more information, type help(envelope) ❼ kernel smoother of point density: 5

> plot(density(mypattern)) density(mypattern) 0.5 1 1.5 2 2.5 For more information, type help(density.ppp) 9. Next if you have additional columns of data recording (for example) the seedling height and seedling sex, you can add these data as marks. Suppose that columns 5 and 9 of the spreadsheet contained such values. Then do something like > marks(mypattern) <- mydata[, c(5,9)] Now you can try things like the kernel smoother of mark values: > plot(smooth(mypattern)) 6

Smooth(mypattern) diameter height 2 2.5 3 3.5 4 4.5 5 2.5 3 3.5 4 10. You are airborne! Now look at the book [2] for more hints. How do I find out which command to use? Information sources for spatstat include: ❼ the Quick Reference guide: a list of the most useful commands. To view the quick reference guide, start R, then type library(spatstat) and then help(spatstat). Alternatively you can download a pdf of the Quick Reference guide from the website www.spatstat.org ❼ online help: ❼ vignettes: The online help files are useful they give detailed information and advice about each command. They are available when you are running spatstat. To get help about a particular command blah, type help(blah). There is a graphical help interface, which you can start by typing help.start(). Alternatively you can download a pdf of the entire manual (1000 pages!) from the website www.spatstat.org. 7

Spatstat comes installed with several vignettes (introductory documents with examples) which can be accessed using the graphical help interface. They include a document about Handling shapefiles. ❼ workshop notes: ❼ book: ❼ website: ❼ forums: References The notes from a two-day workshop on spatstat are available online [1]. These are now rather out-of-date, but still useful. The forthcoming book [2] contains a complete course on spatstat. Visit the spatstat package website www.spatstat.org Join the forum R-sig-geo by visiting r-project.org. Then email your questions to the forum. Alternatively you can ask the authors of the spatstat package (their email addresses are given in the package documentation). [1] A. Baddeley. Analysing spatial point patterns in R. Technical report, CSIRO, 2010. Version 4. URL https://research.csiro.au/software/r-workshop-notes/ [2] A. Baddeley, E. Rubak, and R. Turner. Spatial Point Patterns: Methodology and Applications with R. Chapman & Hall/CRC Press, 2015. [3] R. Bivand, E.J. Pebesma, and V. Gómez-Rubio. Applied spatial data analysis with R. Springer, 2008. [4] N.A.C. Cressie. Statistics for Spatial Data. John Wiley and Sons, New York, second edition, 1993. [5] P.J. Diggle. Statistical Analysis of Spatial Point Patterns. Hodder Arnold, London, second edition, 2003. [6] M.J. Fortin and M.R.T. Dale. Spatial analysis: a guide for ecologists. Cambridge University Press, Cambridge, UK, 2005. [7] A.S. Fotheringham and P.A. Rogers, editors. The SAGE Handbook on Spatial Analysis. SAGE Publications, London, 2009. [8] C. Gaetan and X. Guyon. Spatial statistics and modeling. Springer, 2009. Translated by Kevin Bleakley. [9] A.E. Gelfand, P.J. Diggle, M. Fuentes, and P. Guttorp, editors. Handbook of Spatial Statistics. CRC Press, 2010. [10] J. Illian, A. Penttinen, H. Stoyan, and D. Stoyan. Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, Chichester, 2008. 8

[11] J. Møller and R.P. Waagepetersen. Statistical Inference and Simulation for Spatial Point Processes. Chapman and Hall/CRC, Boca Raton, 2004. [12] D.U. Pfeiffer, T. Robinson, M. Stevenson, K. Stevens, D. Rogers, and A. Clements. Spatial analysis in epidemiology. Oxford University Press, Oxford, UK, 2008. [13] L.A. Waller and C.A. Gotway. Applied spatial statistics for public health data. Wiley, 2004. 9