Vous êtes sur la page 1sur 13

CRAN Task View: Analysis of Spatial Data

Maintainer: Roger Bivand Contact: Roger.Bivand at nhh.no Version: 2013-07-22 Base R includes many functions that can be used for reading, visualising, and analysing spatial data. he focus in this vie! is on "geographical" spatial data, !here observations can be identified !ith geographical locations, and !here additional information about these locations may be retrieved if the location is recorded !ith care. Base R functions are complemented by contributed pac#ages, some of !hich are on $R%&, and others are still in development. 'ne active location is R-(orge , !hich lists ")patial *ata and )tatistics" pro+ects in its pro+ect tree . ,nformation on R-spatial pac#ages, especially sp !ill be posted on the R-(orge rspatial pro+ect !ebsite , including a visualisation gallery. he contributed pac#ages address t!o broad areas- moving spatial data into and out of R, and analysing spatial data in R. he R-),.-.eo mailing-list is a good place to begin for obtaining help and discussing /uestions about both accessing data, and analysing it. he mailing list is a good place to search for information about relevant courses, and a list is hosted at the .eo*a$enter . he pac#ages in this vie! can be roughly structured into the follo!ing topics. ,f you thin# that some pac#age is missing from the list, please let me #no!. 0lease also visit and contribute to the spatial data handling and spatial statistics pages on the R 1i#i.

Classes for spatial data - Because many of the pac#ages importing and using spatial data have had to include ob+ects of storing data and functions for visualising it, an initiative is in progress to construct shared classes and plotting functions for spatial data. he sp pac#age has been published on $R%&. he sp pac#age is discussed in a note in R &e!s . )ome other pac#ages have become dependent on these classes, including rgdal and maptools. (unctions provided by vec2dtransf for applying affine and similarity transformations on vector spatial data 2sp ob+ects3. he rgeos pac#age provides an interface to topology functions for sp ob+ects using .4') . rgeos is no! available for 5ac ')6 on $R%&. he raster pac#age is a ma+or e7tension of spatial data classes to virtualise access to large rasters, permitting large ob+ects to be analysed, and e7tending the analytical tools available for both raster and vector data.

8sed !ith raster9is, it can also provide enhanced visualisation and interaction. he spatial.tools pac#age contains spatial functions meant to enhance the core functionality of the raster pac#age, including a parallel processing engine for use !ith rasters. he micromap pac#age provides lin#ed micromaps using ggplot2. he spacetime pac#age e7tends the shared classes defined in sp for spatio-temporal data. he .rid20olygons converts a spatial ob+ect from class )patial.rid*ata(rame to )patial0olygons*ata(rame. %n alternative approach to some of these issues is implemented in the 0B)mapping pac#age: 0B)modelling provides modelling support. ,n addition, .4'map provides mapping facilities directed to meet the needs of geologists, and uses the geomapdata pac#age.

Handling spatial data - % number of pac#ages have been !ritten using sp classes. he raster pac#age introduces many .,) methods that no! permit much to be done !ith spatial data !ithout having to use .,) in addition to R. ,t may be complemented by gdistance, !hich provided calculation of distances and routes on geographic grids. geosphere permits computations of distance and area to be carried out on spatial data in geographical coordinates. he 5etadata pac#age collects and do!nloads a variety of open .,) datasets that can be used to characteri;e the surface properties of <atitude=<ongitude points, using raster, rgdal and others to access data providers. he spsurvey pac#age provides a range of sampling functions. he trip pac#age e7tends sp classes to permit the accessing and manipulating of spatial data for animal trac#ing. he hdeco pac#age provides hierarchical decomposition of entropy for categorical map comparisons. he .eo6p pac#age permits interactive graphical e7ploratory spatial data analysis. spcosa provides spatial coverage sampling and random sampling from compact geographical strata. he 8)census2000 suite of pac#ages 28)census2000bl#grp, 8)census2000cdp, 8)census2000tract3 ma#es the use of data from the 2000 8) $ensus more convenient. %n important data set, .uerry>s "5oral )tatistics of (rance", has been made available in the .uerry pac#age, !hich provides data and maps and e7amples designed to contribute to the integration of multivariate and spatial analysis. he ne! cshapes and r!orldmap pac#ages ma#e available data sets for conflict studies and environmental studies purposes - they are lin#ed as r!orldmap suggests cshapes.

he landsat pac#age !ith accompanying ?)) paper provides tools for e7ploring and developing correction tools for remote sensing data. taRif7 is a collection of utility and convenience functions, and some interesting spatial functions.

Reading and writing spatial data - rgdal - 5aps may be vector-based or raster-based. he rgdal pac#age provides bindings to .*%< -supported raster formats and '.R -supported vector formats. ,t contains functions to !rite raster files in supported formats. he pac#age also provides 0R'?.@ pro+ection support for vector ob+ects 2 this site provides searchable online 0R'?.@ representations of pro+ections3. he 1indo!s and 5ac ')6 $R%& binaries of rgdal include subsets of possible data source drivers: if others are needed, use other conversion utilities, or install from source against a version of .*%< !ith the re/uired drivers. Reading and writing spatial data - other packages - here are a number of other pac#ages for accessing vector data on $R%&- maps 2!ith mapdata and mappro+3 provides access to the same #inds of geographical databases as ) - R%rc,nfo allo!s %rc,nfo v.7 binary files and A.e00 files to be read, and maptools and shapefiles read and !rite %rc.,)=%rc9ie! shapefiles: for &et$*( files, ncdf may be used. he maptools pac#age also provides helper functions for !riting map polygon files to be read by 1inB8.), 5ondrian, and the tmap command in )tata. ,t also provides interface functions bet!een 0B)mapping and spatstat and sp classes, in addition to maps databases and sp classes. here is also an interface to .)BB) shoreline databases. (or visualisation, the colour palettes provided in the R$olorBre!er pac#age are very useful, and may be modified or e7tended using the colorRampPalette function provided !ith R. he class,nt pac#age provides functions for choosing class intervals for thematic cartography. he gmt pac#age gives a simple interface bet!een .5 map-ma#ing soft!are and R. geonames is an interface to the !!!.geonames.org service. ,f the user !ishes to place a map bac#drop behind other displays, the the Rgoogle5aps pac#age for accessing .oogle 5aps2 53 may be useful. ggmap may be used for spatial visualisation !ith .oogle 5aps and 'pen)treet5ap.plotC5< is a pac#age providing methods for the visualisation of spatial and spatiotemporal ob+ects in .oogle 4arth. 'pen)treet5ap gives access to open street map raster images, and osmar provides infrastructure to access 'pen)treet5ap data from different sources, to !or# !ith the data in common R manner, and to convert data into available infrastructure provided by e7isting R pac#ages.R)urvey may be used as a processing

program for spatially distributed data, and is capable of error corrections and data visualisation. ,ntegration !ith version D.A of the leading open source .,), .R%)), is provided in $R%& pac#age spgrassD, using rgdal for e7changing data. R0y.eo is a !rapper for 0ython access to the %rc.,) .eo0rocessor, and R)%.% is a similar shell-based !rapper for )%.% commands.

Point pattern analysis - he spatial pac#age is a recommended pac#age shipped !ith base R, and contains several core functions, including an implementation of Chat by its author, 0rof. Ripley. ,n addition, spatstat allo!s freedom in defining the region2s3 of interest, and ma#es e7tensions to mar#ed processes and spatial covariates. ,ts strengths are model-fitting and simulation, and it has a usefulhomepage . ,t is the only pac#age that !ill enable the user to fit inhomogeneous point process models !ith interpoint interactions. 5ar#ed0oint0rocess is another contemporary point pattern pac#age. hespatgraphs pac#age provides graphs, graph visualisation and graph based summaries to be used !ith spatial point pattern analysis. he splancs pac#age also allo!s point data to be analysed !ithin a polygonal region of interest, and covers many methods, including 2* #ernel densities. ecespa provides !rappers, functions and data for spatial point pattern analysis, used in the boo# on )patial 4cology of the 4$4)0%=%44 . he functions for binning points on grids in ash may also be of interest. he ads pac#age perform first- and second-order multi-scale analyses derived from Ripley>s C-function. he aspace pac#age is a collection of functions for estimating centrographic statistcs and computational geometries from spatial point patterns. spatial#ernel provides edgecorrected #ernel density estimation and binary #ernel regression estimation for multivariate spatial point process data.*)pat contains functions for spatial modelling for distance sampling data, and spatialsegregation provides segregation measures for multitype spatial point patterns. .rieg)mith uses the .rieg-)mith method on 2 dimensional spatial data. he dbmss pac#age allo!s simple computation of a full set of spatial statistic functions of distance, including classical ones 2Ripley>s C and others3 and more recent ones used by spatial economists 2*uranton and 'verman>s Cd, 5arcon and 0uech>s 53. ,t relies on spatstat for core calculation.

Geostatistics - he gstat pac#age provides a !ide range of functions for univariate and multivariate geostatistics, also for larger datasets,

!hile geoR and geoRglm contain functions for model-based geostatistics. 9ariogram diagnostics may be carried out !ith vardiag. %utomated interpolation using gstat is available in automap. his family of pac#ages is supplemented by intamap !ith procedures for automated interpolation and psgp, !hich implements pro+ected sparse .aussian process #riging. % similar !ide range of functions is to be found in the fields pac#age. he spatial pac#age is shipped !ith base R, and contains several core functions. he spBayes pac#age fits .aussian univariate and multivariate models !ith 5$5$. ramps is a different Bayesian geostatistical modelling pac#age. he geosptpac#age contains some geostatistical and radial basis functions, including prediction and cross validation. Besides, it includes functions for the design of optimal spatial sampling net!or#s based on geostatistical modelling. he Random(ields pac#age provides functions for the simulation and analysis of random fields, and variogram model descriptions can be passed bet!een geoR, gstat and this pac#age. )patial47tremesproposes several approaches for spatial e7tremes modelling using Random(ields. ,n addition, $ompRand(ld, constrainedCriging and geospt provide alternative approaches to geostatistical modelling. hesp imer pac#age is able to fit, spatially predict and temporally forecast large amounts of space-time data using E1F Bayesian .aussian 0rocess 2.03 5odels, E2F Bayesian %uto-Regressive 2%R3 5odels, and E3F Bayesian .aussian 0redictive 0rocesses 2.003 based %R 5odels. he rtop pac#age provides functions for the geostatistical interpolation of data !ith irregular spatial support such as runoff related data or data from administrative units. he georob pac#age provides functions for fitting linear models !ith spatially correlated errors by robust and .aussian Restricted 5a7imum <i#elihood and for computing robust and customary point and bloc# #riging predictions, along !ith utility functions for cross-validation and for unbiased bac#-transformation of #riging predictions of log-transformed data. he )patial ools pac#age has an emphasis on #riging, and provides functions for prediction and simulation. he sgeostat pac#age is also available. 1ithin the same general topical area are the deldir and tripac# pac#ages for triangulation and the a#ima pac#age for spline interpolation: the 5B% pac#age provides scattered data interpolation !ith multilevel B-splines. ,n addition, there are the spatial$ovariance pac#age, !hich supports the computation of spatial covariance matrices for data on rectangles, the regress pac#age building in part on spatial$ovariance, and the tgp pac#age. he )tem pac#age provides for the estimation of the parameters of a spatio-temporal model

using the 45 algorithm, and the estimation of the parameter standard errors using a spatio-temporal parametric bootstrap. (ield)im is another random fields simulations pac#age. he ))& is for geostatistical modeling for data on stream net!or#s, including models based on in-stream distance. 5odels are created using moving average constructions. )patial linear models, including covariates, can be fit !ith 5< or R45<. 5apping and other graphical functions are included.

Disease mapping and areal data analysis - *$luster is a pac#age for the detection of spatial clusters of diseases. ,t e7tends and depends on the spdep pac#age, !hich provides basic functions for building neighbour lists and spatial !eights, tests for spatial autocorrelation for areal data li#e 5oran>s ,, and functions for fitting spatial regression models, such as )%R and $%R models. hese models assume that the spatial dependence can be described by #no!n !eights. he )patial4pi pac#age provides implementations of cluster detection and disease mapping functions, including Bayesian cluster detection, and supports strata. he spg!r pac#age contains an implementation of geographically !eighted regression methods for e7ploring possible non-stationarity. he g!rr pac#age fits geographically !eighted regression 2.1R3 models and has tools to diagnose and remediate collinearity in the .1R models. %lso fits geographically !eighted ridge regression 2.1RR3 and geographically !eighted lasso 2.1<3 models. he .1model pac#age contains functions for computing geographically !eighted models. he sparr pac#age provides another approach to relative ris#s. he $%RBayes pac#age implements Bayesian hierarchical spatial areal unit models. ,n such models the spatial correlation is modelled by a set of random effects, !hich are assigned a conditional autoregressive 2$%R3 prior distribution. 47amples of the models included are the BG5 model as !ell as a recently developed localised spatial smoothing model. he glmmB8.) pac#age is a helpful !ay of passing out spatial models to 1inB8.). he spacom pac#age provides tools to construct and e7ploit spatially !eighted conte7t data, and further allo!s combining the resulting spatially !eighted conte7t data !ith individual-level predictor and outcome variables, for the purposes of multilevel modelling. he geospacom pac#age gnerates distance matrices from shape files and represents spatially !eighted multilevel analysis results. Spatial regression - he choice of function for spatial regression !ill depend on the support available. ,f the data are characterised by point support and the spatial process is continuous, geostatistical methods may be used, or functions in the nlme pac#age. ,f the support is areal, and the

spatial process is not being treated as continuous, functions provided in the spdep pac#age may be used. his pac#age can also be seen as providing spatial econometrics functions, and, as noted above, provides basic functions for building neighbour lists and spatial !eights, tests for spatial autocorrelation for areal data li#e 5oran>s ,, and functions for fitting spatial regression models. ,t provides the full range of local indicators of spatial association, such as local 5oran>s , and diagnostic tools for fitted linear models, including <agrange 5ultiplier tests. )patial regression models that can be fitted using ma7imum li#elihood include spatial lag models, spatial error models, and spatial *urbin models. (or larger data sets, sparse matri7 techni/ues can be used for ma7imum li#elihood fits, !hile spatial t!o stage least s/uares and generalised method of moments estimators are an alternative. 1hen using .55, sphet can be used to accommodate both autocorrelation and heteros#edasticity. )patial count regression is provided using custom 5$5$ by spatcounts. he 5c)patial provides functions for locally !eighted regression, semiparametric and conditionally parametric regression, fourier and cubic spline functions, .55 and lineari;ed spatial logit and probit, #-density functions and counterfactuals, nonparametric /uantile regression and conditional density functions, 5achado-5ata decomposition for /uantile regressions, spatial %R model, repeat sales models, and conditionally parametric logit and probit. he splmpac#age provides methods for fitting spatial panel data by ma7imum li#elihood and .5. spatialprobit ma#e possible Bayesian estimation of the spatial autoregressive probit model 2)%R probit model3.

cological analysis - here are many pac#ages for analysing ecological and environmental data. hey include ade@ for e7ploratory and 4uclidean methods in the environmental sciences, the adehabitatfamily of pac#ages for the analysis of habitat selection by animals 2adehabitatBR, adehabitatB), adehabitat< , and adehabitat5%3, pastecs for the regulation, decomposition and analysis of space-time series, vegan for ordination methods and other useful functions for community and vegetation ecologists, and many other functions in other contributed pac#ages. 'ne such is trip4stimation, basing on the classes provided by trip. ncf has entered $R%& recently, and provides a range of spatial nonparametric covariance functions. range5apper is a pac#age to manipulate species range 2e7tentof-occurrence3 maps, mainly tools for easy generation of biodiversity 2species richness3 or life-history traits maps. 5odel5ap builds on other pac#ages to create models using underlying .,) data. hegstudio pac#age contains classes and functions for the spatial analysis of mar#er data to

include structure statistics, analyses based upon allele fre/uencies, and 0opulation .raphs net!or# analysis of spatial conditional genetic covariance. his pac#age interfaces !ith raster and sp ob+ects directly. %n off-$R%& pac#age - Rcitrus - is for the spatial analysis of plant disease incidence. he .enelandpac#age uses fields and Random(ields to ma#e use of both geographic and genetic informations to estimate the number of populations in a dataset and delineate their spatial organisation. he ngspatialpac#age provides tools for analy;ing spatial data, especially non-.aussian areal data. ,t supports the sparse spatial generali;ed linear mi7ed model of Bughes and Baran 220133 and the centered autologistic model of $aragea and Caiser 2200H3. rlandscape is a tool for generating data 2forests divided into management units3 for testing harvest scheduling models. ,t enables the user to create large amounts of sample forests !hile maintaining control over some spatial properties of the data, such as the degree and area distributions. he 4nvironmetrics as# 9ie! contains a much more complete survey of relevant functions and pac#ages. CRAN packages:

ade@ adehabitat adehabitatBR adehabitatB) adehabitat< adehabitat5% ads a#ima ash aspace automap $%RBayes class,nt 2core3 $ompRand(ld

constrainedCriging cshapes dbmss *$luster 2core3 deldir 2core3 *)pat ecespa fields (ield)im gdistance .eneland .4'map geomapdata geonames geoR 2core3 geoRglm georob geospacom geosphere geospt geospt .eo6p ggmap glmmB8.) gmt

.rid20olygons .rieg)mith gstat 2core3 gstudio .uerry .1model g!rr hdeco intamap landsat mapdata mappro+ maps maptools 2core3 5ar#ed0oint0rocess 5B% 5c)patial 5etadata micromap 5odel5ap ncdf ncf ngspatial nlme 'pen)treet5ap

osmar pastecs 0B)mapping 0B)modelling plotC5< psgp ramps Random(ields 2core3 range5apper R%rc,nfo raster 2core3 raster9is R$olorBre!er 2core3 regress rgdal 2core3 rgeos 2core3 Rgoogle5aps rlandscape R0y.eo R)%.% R)urvey rtop r!orldmap sgeostat shapefiles

sp 2core3 spacetime 2core3 spacom sparr spatcounts spatgraphs spatial spatial.tools spatial$ovariance )patial4pi )patial47tremes spatial#ernel spatialprobit spatialsegregation )patial ools spatstat 2core3 spBayes spcosa spdep 2core3 spgrassD spg!r sphet splancs 2core3 splm spsurvey

sp imer ))& )tem taRif7 tgp trip tripac# trip4stimation 8)census2000bl#grp 8)census2000cdp 8)census2000tract vardiag vec2dtransf vegan

Related links:

$R%& as# 9ie!- 4nvironmetrics Rgeo- )patial )tatistics !ith R R-),.-.eo mailing list

http://cran.at.r-project.org/web/views/Spatial.html

Vous aimerez peut-être aussi