Learn R Programming

tmap (version 0.7)

tm_shape: Specify the shape object

Description

Creates a tmap-element that specifies the shape object. Also the projection and covered area (bounding box) can be set. It is possible to use multiple shape objects within one plot (see tmap-element).

Usage

tm_shape(shp, projection = NULL, xlim = NULL, ylim = NULL,
  relative = TRUE, bbox = NULL)

Arguments

shp
shape object, which is one of
  1. SpatialPolygons(DataFrame)

Value

item

  • projection
  • xlim
  • ylim
  • relative
  • bbox

code

ylim

describe

  • "longlat"Not really a projection, but a plot of the longitude-latitude coordinates (WGS84 datum).
  • "wintri"Winkel Tripel (1921). Popular projection that is useful in world maps. It is the standard of world maps made by the National Geographic Society. Type: compromise
  • "robin"Robinson (1963). Another popular projection for world maps. Type: compromise
  • "eck4"Eckert IV (1906). Projection useful for world maps. Area sizes are preserved, which makes it particularly useful for truthful choropleths. Type: equal-area
  • "hd"Hobo-Dyer (2002). Another projection useful for world maps in which area sizes are preserved. Type: equal-area
  • "gall"Gall (Peters) (1855). Another projection useful for world maps in which area sizes are preserved. Type: equal-area
  • "merc"Mercator (1569). Projection in which shapes are locally preserved. However, areas close to the poles are inflated. Google Maps uses a close variant of the Mercator. Type: conformal
  • "utmXX(s)"Universal Transverse Mercator. Set of 60 projections where each projection is a traverse mercator optimized for a 6 degree longitude range. These ranges are called UTM zones. Zone 01 covers -180 to -174 degrees (West) and zone 60 174 to 180 east. Replace XX in the character string with the zone number. For southern hemisphere, add "s". So, for instance, the Netherlands is "utm31" and New Zealand is "utm59s"
  • "mill"Miller (1942). Projetion based on Mercator, in which poles are displayed. Type: compromise
  • "eqc0"Equirectangular (120). Projection in which distances along meridians are conserved. The equator is the standard parallel. Also known as Plate Carr'ee. Type: equidistant
  • "eqc30"Equirectangular (120). Projection in which distances along meridians are conserved. The latitude of 30 is the standard parallel. Type: equidistant
  • "eqc45"Equirectangular (120). Projection in which distances along meridians are conserved. The latitude of 45 is the standard parallel. Also known as Gall isographic. Type: equidistant
  • "rd"Rijksdriehoekstelsel. Triangulation coordinate system used in the Netherlands.

url

  • http://en.wikipedia.org/wiki/List_of_map_projections
  • http://trac.osgeo.org/proj/

See Also

read_shape to read ESRI shape files, set_projection, ../doc/tmap-nutshell.html{vignette("tmap-nutshell")}

Examples

Run this code
data(World)
data(cities)
data(rivers)

tm_shape(World, projection="longlat") + 
    tm_fill() +
    tm_borders() + 
    tm_layout("Long lat coordinates (WGS84)", inner.margins=c(0,0,.1,0), title.cex=.8)

World$highlighted <- ifelse(World$iso_a3 %in% c("GRL", "AUS"), "gold", "gray75")
tm_shape(World, projection="merc") + 
	tm_fill("highlighted") + 
	tm_borders() + 
	tm_layout("Mercator projection. Although used in Google Maps, it is discouraged for
statistical purposes. In reality, Australia is 3 times larger than Greenland!", 
			  inner.margins=c(0,0,.1,0), title.cex=.6)

tm_shape(World, projection="wintri") + 
    tm_fill() + 
    tm_borders() + 
    tm_layout(
"Winkel-Tripel projection, adapted as default by the National Geographic Society for world maps.", 
inner.margins=c(0,0,.1,0), title.cex=.8)

tm_shape(World) +
    tm_fill() + 
    tm_borders() + 
tm_layout("Eckhart IV projection. Recommended in statistical maps for its equal-area property.", 
    inner.margins=c(0,0,.1,0), title.cex=.8)

# three groups of layers, each starting with tm_shape
tm_shape(World) +
	tm_fill("darkolivegreen3") +
tm_shape(cities) +
	tm_bubbles("pop_max", col = "grey30", scale=.5) +
tm_shape(rivers) +
	tm_lines("lightcyan1") +
tm_layout_World(title = "", bg.color="lightcyan1", legend.show = FALSE)

Run the code above in your browser using DataLab