Learn R Programming

tmap (version 0.7)

tmap-element: tmap element

Description

Building block for drawing thematic maps.

Arguments

Details

The only fundamental, and hence required element is
  • tm_shapethat specifies the shape object, and also controls the projection and bounding box
The elements that serve as drawing layers are The layers can be stacked by simply adding them with the + symbol. The combination of the elements described above form one group. Multiple groups can be stacked. Each group should start with tm_shape (see examples below). The layout elements are
  • tm_layoutto change the appearance of the map, for instance titles, legend positions, and margins. Predefined themes for the example shape files aretm_layout_World,tm_layout_Europe, andtm_layout_NLD.
  • tm_facetsthat specifies how small multiples are created, i.e. how many rows and colums, and whether the statistical data variables have free scales or not.
  • tm_gridthat specifies coordinate grid lines

Examples

Run this code
data(World)
data(Europe)
data(NLD_muni)
data(NLD_prov)
data(cities)

qtm(Europe)

qtm(World, fill = "economy", text="iso_a3", text.cex = "AREA", fill.palette="-Blues", 
	theme = "World", title="Economy")

tm_shape(World) +
	tm_fill("pop_est_dens", style="kmeans", palette="YlOrRd") +
	tm_borders() +
	tm_text("iso_a3", cex="AREA", cex.lowerbound=.4) +
	tm_layout_World(title="Population density per km2")

tm_shape(Europe) +
	tm_borders() +
	tm_fill() +
tm_shape(cities) +
	tm_bubbles(size="pop_max", col="capital", size.lim=c(0, 2e7)) +
	tm_text("name", cex="pop_max", scale=2, root=3, ymod=-.015, bg.alpha=0) +
	tm_layout_Europe("Metropolitan population", legend.titles=c(bubble.col="Capital"))

tm_shape(NLD_muni) +
	tm_borders() +
	tm_facets(by="province") +
	tm_fill("population", style="kmeans", convert2density = TRUE) +
	tm_shape(NLD_prov) +
	tm_borders(lwd=4) +
	tm_facets(by="name", free.coords=TRUE, drop.shapes=TRUE) +
	tm_layout(legend.show = FALSE)

Run the code above in your browser using DataLab