Learn R Programming

btb (version 0.1.14)

kernelSmoothing: Smoothing function (Fonction de lissage)

Description

Smoothing function with a bisquare kernel or median.

(Fonction de lissage <U+00E0> partir d'un noyau bisquare ou de la m<U+00E9>diane.)

Usage

# Call mode 1: bisquare kernel smoothing - automatic grid
  kernelSmoothing(  dfObservations
                  , cellSize
                  , bandwidth
                  , vQuantiles = NULL
                  , dfCentroids = NULL
                  , fUpdateProgress = NULL
                  , neighbor = NULL
  )
 
  # Call mode 2: median smoothing - automatic grid
  kernelSmoothing(  dfObservations
                  , cellSize
                  , bandwidth
                  , vQuantiles
                  , dfCentroids = NULL
                  , fUpdateProgress = NULL
                  , neighbor = NULL
  )
  
  # Call mode 3: bisquare kernel smoothing - user grid
  kernelSmoothing(  dfObservations
                  , cellSize
                  , bandwidth
                  , vQuantiles = NULL
                  , dfCentroids
                  , fUpdateProgress = NULL
                  , neighbor = NULL
  )
  
  # Call mode 4: median smoothing - user grid
  kernelSmoothing(  dfObservations
                  , cellSize
                  , bandwidth
                  , vQuantiles
                  , dfCentroids
                  , fUpdateProgress = NULL
                  , neighbor = NULL
  )

Arguments

dfObservations

A data.frame with geographical coordinates and variables to smooth. (x, y, var1, var2, ...)

(Un data.frame comportant les coordonn<U+00E9>es g<U+00E9>ographiques (x,y), ainsi que les variables que l'on souhaite lisser.)

cellSize

Cell size of the grid (integer). The unit of measurement is free. It must be the same as the unit of bandwidth variable.

(Taille des carreaux (integer). Le choix de l'unit<U+00E9> de mesure est laiss<U+00E9> libre <U+00E0> l'utilisateur. Elle doit seulement <U+00EA>tre la m<U+00EA>me que celle de la variable bandwidth.)

bandwidth

Radius of the Kernel Density Estimator (integer). This bandwidth acts as a smoothing parameter, controlling the balance between bias and variance. A large bandwidth leads to a very smooth (i.e. high-bias) density distribution. A small bandwidth leads to an unsmooth (i.e. high-variance) density distribution. The unit of measurement is free. It must be the same as the unit of cellSize variable.

(Rayon de lissage de l'estimation d'intensit<U+00E9> par noyau (integer). Cette bande-passante se comporte comme un param<U+00E8>tre de lissage, controlant l'<U+00E9>quilibre entre biais et variance. Un rayon <U+00E9>lev<U+00E9> conduit <U+00E0> une densit<U+00E9> tres liss<U+00E9>e, avec un biais <U+00E9>lev<U+00E9>. Un petit rayon g<U+00E9>n<U+00E8>re une densit<U+00E9> peu liss<U+00E9> avec une forte variance. Le choix de l'unit<U+00E9> de mesure est laiss<U+00E9> libre <U+00E0> l'utilisateur. Elle doit seulement <U+00EA>tre la m<U+00EA>me que celle de la variable cellSize.

vQuantiles

Percentile vector to calculate. For example c(0.1, 0.25, 0.5) will calculate the first decile, the first quartile and the median.

(Vecteur des quantiles <U+00E0> calculer. Par exemple c(0.1, 0.25, 0.5) retournera le premier d<U+00E9>cile, le premier quartile et la mediane.)

dfCentroids

A data.frame with two columns (x, y) containing coordonates of the user's centroids. (Un data.frame avec deux colonnes (x, y) contenant les coordonn<U+00E9>es des centroides de l'utilisateur.)

fUpdateProgress

A function to see compute progress. (Une function pour voir la progression du calcul.)

neighbor

Technical parameter, leave empty. (integer)

(Param<U+00E8>tre technique pour calculer l'<U+00E9>tendue des points d'estimations, <U+00E0> ne pas remplir. (integer))

Details

Returns an object inheriting from the data.frame class. (Retourne un objet qui se comporte comme un data.frame, par heritage.)

  • Smoothing covers a set of methods to extract pertinent and structuring information from noisy data. In the field of spatial analysis, and most widely in quantiative geography, smoothing is used to modelise density variations of a population distribution in geographical space. Kernel smootthing methods are widely used. In this method, for each location x, we count the number of events of a process within a distance h of x, and weighted by the square reciprocal of the radius h. We apply a edge-correction to deal with edge-effects. So the method is conservative..

  • Le lissage recouvre un ensemble de methodes pour extraire d'une source de donn<U+00E9>es bruit<U+00E9>es une information pertinente et structurante. Dans le champ de l'analyse spatiale et plus largement de la g<U+00E9>ographie quantitative, le lissage est principalement utilis<U+00E9> pour mod<U+00E9>liser les variations de densites d'une distribution de population dans l'espace g<U+00E9>ographique. On utilise principalement des m<U+00E9>thodes de lissage par noyau. Il s'agit ici, pour chaque point x, de comptabliser le nombre d'"<U+00E9>venements" d'un processus <U+00E0> une distance h de ce point, tout en ponderant ce nombre par l'inverse de la distance h au carr<U+00E9>. On applique une correction <U+00E0> la ponderation afin de traiter les effets de bord. Cette m<U+00E9>thode est conservative.

References

  • "Geographically weighted summary statistics : a framework for localised exploratory data analysis", C.Brunsdon & al., in Computers, Environment and Urban Systems 2002

  • Statistical Analysis of Spatial and Spatio-Temporal Point Patterns, Third Edition, Diggle, 2003, pp. 83-86

Examples

Run this code
# NOT RUN {
data(reunion)
# Smoothing all variables for Reunion (Lissage de toutes les variables pour la Reunion)

# Call mode 1: classic smoothing - automatic grid
reunionSmooth <- kernelSmoothing( dfObservations = reunion
                                , cellSize = 200
                                , bandwidth = 400)

# Call mode 2: median smoothing - automatic grid
reunionSmooth <- kernelSmoothing( dfObservations = reunion
                                , cellSize = 200
                                , bandwidth = 400
                                , vQuantiles = c(0.1, 0.5, 0.9))

# Call mode 3: classic smoothing - user grid
dfCentroidsUser <- merge( x = seq(from =  314400, to =  378800, by = 200)
                        , y = seq(from = 7634000, to = 7691200, by = 200))
reunionSmooth <- kernelSmoothing( dfObservations = reunion
                                , cellSize = 200
                                , bandwidth = 400
                                , dfCentroids = dfCentroidsUser)

# Call mode 4: median smoothing - user grid
reunionSmooth <- kernelSmoothing( dfObservations = reunion
                                , cellSize = 200
                                , bandwidth = 400
                                , vQuantiles = c(0.1, 0.5, 0.9)
                                , dfCentroids = dfCentroidsUser)

# Building of the associated basemap (Creation du fond de carte associe)
grid <- smoothingToGrid(reunionSmooth, "32740")

# preview (Apercu)
library(sp)
library(cartography)
cartography::choroLayer(grid, var = "houhold", nclass = 5
                      , method = "fisher-jenks", border = NA)

# Export of the basemap in shapefile format (Export du fond de carte au format shapefile)
library(rgdal)
rgdal::writeOGR(grid, "reunion.shp", "reunion", driver = "ESRI Shapefile")
# }

Run the code above in your browser using DataLab