tmap: Thematic Maps
{ggplot2}
風に操作できる主題図を描くためのパッケージ
- CRAN: http://cran.r-project.org/web/packages/tmap/index.html
- GitHub: https://github.com/mtennekes/tmap
> library(tmap)
> data("World")
> data("Europe")
> data("NLD_prov")
> data("NLD_muni")
バージョン: 1.2
関数名 | 概略 |
---|---|
+.tmap |
Stacking of tmap elements World World, Europe, and Netherlands map |
animation_tmap |
Create animations |
append_data |
Append data to a shape object |
approx_areas |
Approximate area sizes of the shapes |
calc_densities |
Calculate densities |
get_IDs |
Get ID's of the shape items |
get_asp_ratio |
Get aspect ratio |
land |
Spatial data of global land cover |
metro |
Spatial data of metropolitan areas |
print.tmap |
Draw thematic map |
qtm |
Quick thematic map plot |
read_shape |
Read shape file |
rivers |
Spatial data of rivers |
sbind |
Combine shape objects |
set_projection |
Set and get the map projection |
split.SpatialPolygonsDataFrame |
Divide into multiple shape objects |
tm_bubbles |
Draw bubbles |
tm_credits |
Credits text |
tm_facets |
Small multiples |
tm_fill |
Draw polygons |
tm_grid |
Coordinate grid lines |
tm_layout |
Layout elements of cartographic maps |
tm_lines |
Draw spatial lines |
tm_raster |
Draw a raster |
tm_scale_bar |
Scale bar |
tm_shape |
Specify the shape object |
tm_text |
Add text labels |
tmap-element |
tmap element |
tmap-package |
Thematic Maps |
write_shape |
Write shape file |
Europe
> data("Europe")
> Europe %>% dim()
[1] 70 15
land
空間データ
> data("land")
> land %>% str()
Formal class 'SpatialGridDataFrame' [package "sp"] with 4 slots
..@ data :'data.frame': 583200 obs. of 4 variables:
.. ..$ cover : Factor w/ 20 levels "Broadleaf Evergreen Forest",..: 20 20 20 20 20 20 20 20 20 20 ...
.. ..$ cover_cls: Factor w/ 8 levels "Forest","Other natural vegetation",..: 8 8 8 8 8 8 8 8 8 8 ...
.. ..$ trees : int [1:583200] NA NA NA NA NA NA NA NA NA NA ...
.. ..$ elevation: int [1:583200] NA NA NA NA NA NA NA NA NA NA ...
..@ grid :Formal class 'GridTopology' [package "sp"] with 3 slots
.. .. ..@ cellcentre.offset: Named num [1:2] -179.8 -89.8
.. .. .. ..- attr(*, "names")= chr [1:2] "x" "y"
.. .. ..@ cellsize : num [1:2] 0.333 0.333
.. .. ..@ cells.dim : int [1:2] 1080 540
..@ bbox : num [1:2, 1:2] -180 -90 180 90
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "x" "y"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
metro
空間データ
> data("metro")
> metro %>% str()
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
..@ data :'data.frame': 436 obs. of 12 variables:
.. ..$ name : chr [1:436] "Kabul" "Algiers" "Luanda" "Buenos Aires" ...
.. ..$ name_long: chr [1:436] "Kabul" "El Djazair (Algiers)" "Luanda" "Buenos Aires" ...
.. ..$ iso_a3 : chr [1:436] "AFG" "DZA" "AGO" "ARG" ...
.. ..$ pop1950 : num [1:436] 170784 516450 138413 5097612 429249 ...
.. ..$ pop1960 : num [1:436] 285352 871636 219427 6597634 605309 ...
.. ..$ pop1970 : num [1:436] 471891 1281127 459225 8104621 809794 ...
.. ..$ pop1980 : num [1:436] 977824 1621442 771349 9422362 1009521 ...
.. ..$ pop1990 : num [1:436] 1549320 1797068 1390240 10513284 1200168 ...
.. ..$ pop2000 : num [1:436] 2401109 2140577 2591388 12406780 1347561 ...
.. ..$ pop2010 : num [1:436] 3722320 2432023 4508434 14245871 1459268 ...
.. ..$ pop2020 : num [1:436] 5721697 2835218 6836849 15894307 1562509 ...
.. ..$ pop2030 : num [1:436] 8279607 3404575 10428756 16956491 1718192 ...
..@ coords.nrs : num(0)
..@ coords : num [1:436, 1:2] 69.17 3.04 13.23 -58.4 -64.18 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:436] "2" "8" "13" "16" ...
.. .. ..$ : chr [1:2] "Longitude" "Latitude"
..@ bbox : num [1:2, 1:2] -123.1 -37.8 174.8 60.2
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "Longitude" "Latitude"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
qtm
簡単な主題図を描画する
> data("Europe")
> qtm(Europe)
read_shape
shapeファイルの読み込み
> read_shape(file, current.projection = NULL, ...)
tm_shape
> data(World, metro)
> tm_shape(World, projection="longlat") +
+ tm_polygons() +
+ tm_layout("Long lat coordinates (WGS84)", inner.margins=c(0,0,.1,0), title.size=.8)
World
> data("World")
> World %>% {
+ print(.)
+ class(.)
+ }
class : SpatialPolygonsDataFrame
features : 177
extent : -16656124, 16656124, -8451673, 8375779 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=eck4 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0
variables : 15
names : iso_a3, name, sovereignt, continent, subregion, area, pop_est, pop_est_dens, gdp_md_est, gdp_cap_est, economy, income_grp, life_exp, well_being, HPI
min values : AFG, Afghanistan, Afghanistan, Africa, Antarctica, 2590.000, 140, 0.0003498711, 16.00, 300.4693, 1. Developed region: G7, 1. High income: OECD, 47.8, 2.807855, 22.59117
max values : ZWE, Zimbabwe, Zimbabwe, South America, Western Europe, 16376870.000, 1338612970, 1198.8237151417, 15094000.00, 200000.0000, 7. Least developed region, 5. Low income, 83.4, 7.770515, 64.03593
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
> data("Europe")
> data("NLD_prov")
> data("NLD_muni")