Learn R Programming

tmap (version 0.7)

convert_shape_data: Convert shape data

Description

Convert numeric data from one polygon shape to another. It uses an intersection matrix, which stores the intersection ratios of the two shape objects per polygon (see intersection_shapes).

Usage

convert_shape_data(shp.from, shp.to, variables.from = NULL,
  variables.to = NULL)

Arguments

shp.from
the shape object, i.e. a SpatialPolygons(DataFrame), to be converted. It should contain data.
shp.to
the shape object, i.e. a SpatialPolygons(DataFrame), to be converted into.
variables.from
names of the numeric variables of shp.from to be converted. If missing, all numeric variables are taken.
variables.to
variable names to be used. Should be the same number of variable names as variables.from

Value

  • Shape object shp.to with converted data from shp.from.

Examples

Run this code
data(NLD_prov)
data(NLD_muni)

## Compare to the original province population data
qtm(NLD_muni, fill="population", convert2density = TRUE)
qtm(NLD_prov, fill="population", convert2density = TRUE)

## For illustration, the population of provinces is derived from the municipality data
NLD_prov <- convert_shape_data(NLD_muni, NLD_prov, variables.from = "population")
qtm(NLD_prov, fill="population.data", convert2density = TRUE)

## Now, the population of province level is spread equally over the municipalities
NLD_muni <- convert_shape_data(NLD_prov, NLD_muni, variables.from = "population")
qtm(NLD_muni, fill="population.data", convert2density = TRUE)

Run the code above in your browser using DataLab