GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial Econometric Association Conference - Toulouse 2011
Thibault LAURENT, Anne RUIZ-GAZEN and Christine THOMAS-AGNAN GREMAQ, Toulouse School of Economics
7 juillet 2011
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis
1 Introduction 2 Spatial statistics with R 3 GeoXp : Interactivity between statistic plots with maps 4 An application on real data 5 Innovations of GeoXp 6 Perspectives
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Introduction
Data Set A data set of n observations and p variables (discrete, continuous) :
Individuals 1 2 .. .
1 x11 x21 .. .
n
xn1
Variables ... ... ... ... ...
p x1p x2p .. . xnp
Each observation is associated to a a spatial object (a point, a line or a polygon).
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Introduction
Definition and objectives of Spatial Exploratory Data Analysis (SEDA)
Definition : combine information given by techniques of EDA with spatial information using mapping, interactivity between statistical plots with maps or by creating new methods using for example neighborhood matrices. Objectives : give qualitative response to the usual problems of spatial analysis like detection of spatial autocorrelation, detection of local or global extreme values, detection of spatial heterogeneity...
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Introduction
SEDA softwares Because GIS do not take into account enough statistical methodology, researchers in spatial statistics have developed softwares which take into account this methodology : GeoDa (L. Anselin, https://www.geoda.uiuc.edu/) Spatial Econometric Toolbox on Matlab (K. Pace - J. LeSage, http://www.spatial-econometrics.com/) Many R packages (R. Bivand maintains the spatial Task Views http://cran.r-project.org/web/views/Spatial.html see also the R Wiki http://wiki.r-project.org/rwiki/doku.php?id=tips: spatial-data). Spatial Econometric with Gauss T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
1 Introduction 2 Spatial statistics with R 3 GeoXp : Interactivity between statistic plots with maps 4 An application on real data 5 Innovations of GeoXp 6 Perspectives
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Spatial statistic with R
R, GNU projet http://cran.r-project.org/ R. Bivand, E. Pebezma, V. Gomez-Rubio (2008), Applied Spatial Data Analysis with R, Springer-Verlag. R Spatial task view http://cran.r-project.org/web/views/Spatial.html Main packages for mapping : rgdal and maptools (import/export of spatial files, convert CRS/projection, etc), sp (definition of the Spatial classes and methods) and raster (for images).
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Mapping with R
1
import the spatial file (.shp, .MIF, etc) into R (readShapeFile, etc). There exists four main kind of sptatial objects : points, polygons, lines, pixels.
2
eventually, change the CRS/projection
3
use the functions plot, points, legend, etc. for mapping.
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Mapping with R : example
library(sp) library(maptools) xx = readShapePoly("NY8_utm18.shp",IDvar="AREAKEY", CRS("+proj=utm +zone=18 +datum=WGS84")) plot(xx,main="NY data",col=’blue3’) title("N-Y Leukemia Data")
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Representation of
and
SpatialPointsDataFrame
SpatialPolygonDataFrame
objects
Core−periphery / Income in Columbus OH
Soil Sample near the Meuse river
Core−periphery dummy
Type of soil ●
E S
0
● 2.1
● 3.2
● 3.7
●●● ● ● ● ●● ●● ● ● ● ●● ● ●●● ● ●● ●
N W
Income
0 1
1 2 3
1000 m
●● ● ●● ●● ● ● ●● ● ●● ● ● ● ● ● ● ●●● ● ● ● ●● ● ●●●● ● ●●●● ● ● ● ●●● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ●
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
● 4.3
●5.6
●
●
●
●
●
●
● ●
●
●
● ●
●
●
●
●
● ● ● ●
● ● ●
●
●
●
● ●
●● ● ●
● ●
● ● ●
● ● ●
●
●
●
● ● ●
● ● ●
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Representation of
raster
and
PolyLines
object
333000
49.5
334000
Vancouver Island
331000
1000
49
Latitude (°)
332000
1500
LTS Survey Tracks
330000
48.5
500
500−800 m 800−1200 m 1200−1600 m
178000
179000
180000
181000
182000
−127.5
−127
−126.5
−126
Longitude (°)
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Spatial statistics with R
Some advices
Which projection system ? Which reference system (very important to give units to the distances) ? Choice of palettes is important (see RColorBrewer package). How find class intervals for continuous numerical variables : classInt package (“equal interval”, “quantile”, “K-means”, etc). Interpolation can be useful to have a global view of spatial distribution (variables, residuals, coefficients of GWR model, etc), see package akima.
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Interactivity
1 Introduction 2 Spatial statistics with R 3 GeoXp : Interactivity between statistic plots with maps 4 An application on real data 5 Innovations of GeoXp 6 Perspectives
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Interactivity
Package GeoXp
Package GeoXp : interactive spatial exploratory data analysis may be download on http://cran.r-project.org. a vignette : vignette("presentation_geoxp"). use the sp norm as defined by R. Bivand et al. T. Laurent, A. Ruiz-Gazen et C. Thomas-Agnan (Forthcoming), “GeoXp : an R package for Exploratory Spatial Data Analysis”, JSS. GeoXp, also available on Matlab
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Interactivity
Use of GeoXp Arguments of a GeoXp function xxxmap (ex : histomap, barmap, densitymap, etc) : a spatial object of class SpatialxxxDataFrame the name of the studied variable(s) (univariate or multivariate analysis) options (colors, legend, etc.) 3 main kind of functions : univariate analysis : histomap(columbus,"CRIME") bivariate analysis : polyboxplotmap(columbus,c("CRIME","CP"))
spatial econometric function - spatial weight matrix (moranplotmap, neighbourmap, etc.) T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Interactivity
GeoXp visual A Tcl/Tk window, a map and a graphic
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Application
1 Introduction 2 Spatial statistics with R 3 GeoXp : Interactivity between statistic plots with maps 4 An application on real data 5 Innovations of GeoXp 6 Perspectives
T. Laurent, A. Ruiz-Gazen and C. Thomas-Agnan
GeoXp: an R package for exploratory spatial Data analysis
GeoXp: an R package for exploratory spatial Data analysis Application
Lorenz curve
data(mp.school) coordinates(mp.school)