sdc_raster
creates multiple raster::raster
objects
("count", "mean", "sum") from supplied point data x
and calculates
the sensitivity to privacy disclosure for each raster location.
Usage
sdc_raster(
x,
variable,
r = 200,
max_risk = 0.95,
min_count = 10,
risk_type = c("external", "internal", "discrete"),
...,
field = variable
)
Arguments
- x
sp::SpatialPointsDataFrame, sf::sf or a two column matrix or data.frame that is used to create a raster map.
- variable
name of data column or
numeric
with same length asx
to be used for the data in the raster map.- r
either a desired resolution or a pre-existing raster object. In the first case, the crs of
x
(if present) will be used, in the latter the properties of ther
will be kept.- max_risk
numeric
, the maximum_risk score (disclosure_risk
) before a cell in the map is considered sensitive.- min_count
numeric
, a raster cell with less thenmin_count
observations is considered sensitived.- risk_type
passed on to
disclosure_risk()
.- ...
passed through to
raster::rasterize()
- field
synonym for
variable
. If both supplied,field
has precedence.
Value
object of class
"sdc_raster":
$value
:raster::brick()
object with different layers e.g.count
,sum
,mean
,scale
.$max_risk
: see above.$min_count
: see above. of protection operationprotect_smooth()
orprotect_quadtree()
.$type
: data type ofvariable
, eithernumeric
orlogical
$risk_type
, "external", "internal" or "discrete" (seedisclosure_risk()
)
Details
A sdc_raster
object is the vehicle that does the book keeping for calculating
sensitivity. Protection methods work upon a sdc_raster
and return a new
sdc_raster
in which the sensitivity is reduced.
The sensitivity of the map can be assessed with sensitivity_score,
plot.sdc_raster()
, plot_sensitive()
or print
.
Reducing the sensitivity can be done with protect_smooth()
,
protect_quadtree()
and remove_sensitive()
. Raster maps for mean
,
sum
and count
data can be extracted from the $value
(brick()
).
See also
Other sensitive:
disclosure_risk()
,
is_sensitive_at()
,
is_sensitive()
,
plot_sensitive()
,
remove_sensitive()
,
sensitivity_score()
Examples
# \donttest{
library(raster)
prod <- sdc_raster(enterprises, field = "production", r = 500)
print(prod)
#> numeric sdc_raster object:
#> resolution: 500 500 , max_risk: 0.95 , min_count: 10
#> mean sensitivity score [0,1]: 0.6432039
prod <- sdc_raster(enterprises, field = "production", r = 1e3)
print(prod)
#> numeric sdc_raster object:
#> resolution: 1000 1000 , max_risk: 0.95 , min_count: 10
#> mean sensitivity score [0,1]: 0.255814
# get raster with the average production per cell averaged over the enterprises
prod_mean <- mean(prod)
summary(prod_mean)
#> layer
#> Min. 383.4914
#> 1st Qu. 1425.1032
#> Median 2463.0075
#> 3rd Qu. 4150.8754
#> Max. 11871.0465
#> NA's 6.0000
# get raster with the total production per cell
prod_total <- sum(prod)
summary(prod_total)
#> sum
#> Min. 1115.291
#> 1st Qu. 14887.530
#> Median 58206.438
#> 3rd Qu. 178065.698
#> Max. 2435076.047
#> NA's 6.000
# }