smooth_shapefile: Smooth a shapefile by nearest neighbourhood

View source: R/smooth_shapefile.R

smooth_shapefileR Documentation

Smooth a shapefile by nearest neighbourhood

Description

Given a shapefile and a data.frame with a value for each polygon, return a smoothed value of the values.

Usage

smooth_shapefile(
  shapefile,
  data_by_id,
  id,
  var2smooth,
  k = 10,
  coalesce.to = 0
)

Arguments

shapefile

A shapefile (as from this package) containing an as.data.frame method.

data_by_id

A data.frame containing a value for each polygon within shapefile.

id

The key of data_by_id on which the shapefile may be merged with shapefile.

var2smooth

A length-one character vector indicating which variable in data_by_id to smooth.

k

Passed to knearneigh.

coalesce.to

A single value. If there are any missing values in data_by_id[[id]], what should these be imputed as? Must have the same storage mode as data_by_id[[id]].

Value

A vector of values representing the smoothed version of data_by_id[[id]].


HughParsonage/ASGS documentation built on Jan. 17, 2024, 12:16 p.m.