tm_shape | R Documentation |
Specify a shape, which is a spatial object from one of these spatial object
class packages: sf
, stars
, or terra
.
tm_shape(
shp,
bbox = NULL,
crs = NULL,
is.main = NA,
name = NULL,
unit = NULL,
filter = NULL,
...
)
shp |
Spatial object |
bbox |
Bounding box of the map (only used if |
crs |
Map projection (CRS). Can be set to an |
is.main |
Is |
name |
of the spatial object |
unit |
Unit of the coordinates |
filter |
Filter features |
... |
passed on to |
The map projection (crs
) determines in which coordinate system the spatial object is processed and plotted.
See vignette about CRS. The crs
can be specified in two places: 1) tm_shape()
and tm_crs()
.
In both cases, the map is plotted into the specified crs
. The difference is that in the first option, the crs
is also taken into account in spatial transformation functions, such as the calculation of centroids and cartograms. In the second option, the crs
is only used in the plotting phase.
The automatic crs recommendation (which is still work-in-progress) is the following:
Property | Recommendation |
global (for world maps) | A pseudocylindrical projection tmap option crs_global , by default "eqearth (Equal Eearth). See https://r-tmap.github.io/tmap/articles/41_advanced_crs.html for more options |
area (equal area) | Lambert Azimuthal Equal Area (laea ) |
distance (equidistant) | Azimuthal Equidistant (aeqd ) |
shape (conformal) | Stereographic (stere ) |
For further info about the available "generic" projects see: for utm: https://proj.org/en/9.4/operations/projections/utm.html for laea: https://proj.org/en/9.4/operations/projections/laea.html for aeqd: https://proj.org/en/9.4/operations/projections/aeqd.html for pconic: https://proj.org/en/9.4/operations/projections/pconic.html for eqdc: https://proj.org/en/9.4/operations/projections/eqdc.html
as of tmap 4.0, simplify has been removed. Please use tmaptools::simplify_shape()
instead
tm_shape(World, crs = "auto") +
tm_polygons()
tm_shape(World, crs = 3035, bb = "Europe") +
tm_polygons()
tm_shape(World, crs = "+proj=robin", filter = World$continent=="Africa") +
tm_polygons()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.