tmap
uses ESRI Shapefiles- read them in using
read_shape
- Shortcut to creating maps
qtm
- quick thematic map
tmap
objects quite similar toggplot
objects- First up, load the packages you need
tmap
works well withdplyr
library(tmap) library(dplyr)
tmap
uses ESRI Shapefilesread_shape
qtm
tmap
objects quite similar to ggplot
objectstmap
works well with dplyr
library(tmap) library(dplyr)
read_shape('./counties/counties.shp') -> cty cty %>% qtm
cty %>% qtm(fill="POPDENSITY")
cty %>% qtm(fill='POPDENSITY') -> cty_dens cty_dens + tm_compass()
cty %>% qtm(fill='POPDENSITY') -> cty_dens cty_dens + tm_compass() + tm_style_natural()
cty %>% qtm(fill='POPDENSITY') -> cty_dens cty_dens + tm_compass() + tm_style_col_blind()
qtm(cty,projection="+init=epsg:29900",fill="POPDENSITY") + tm_scale_bar()
cty %>% set_projection("+init=epsg:29900") -> cty2 tm_shape(cty2) + tm_style_classic() + tm_fill(col="POPDENSITY",title='Population Density') + tm_borders() + tm_compass(size=4)
cty2 %>% cartogram(weight="TOTAL2011") -> cart cart %>% qtm
tm_shape(cart) + tm_fill(col="PCVAC20111",title='% Vacant Houses') + tm_borders()
tm_shape(cty2) + tm_fill(col=c("PCVAC20111","POPDENSITY"),title=c('% Vacant Houses','Population Density')) + tm_borders()
tm_shape(cty2) + tm_fill(col=c("PCVAC20111","POPDENSITY"),title=c('% Vacant Houses','Population Density')) + tm_borders() + tm_layout(panel.labels=c("Vacancy","Density"))
tm_shape(cty2) + tm_fill(col=c("PCVAC20111","POPDENSITY"),title=c('% Vacant Houses','Population Density')) + tm_borders() + tm_layout(panel.labels=c("Vacancy","Density")) + tm_scale_bar()
tm_shape(cty) + tm_fill(col="PCVAC20111",title='% Vacant Houses',style='jenks') + tm_borders() -> cmap tmap_leaflet(cmap)
tmap_mode("view") tm_shape(cty) + tm_fill(col="PCVAC20111",title='% Vacant Houses',style='jenks') + tm_borders() -> cmap cmap + tm_view(basemaps = c("Stamen.Watercolor","OpenStreetMap.BlackAndWhite"), alpha=0.5)
gael <- read_shape('./Gael/Census2011_Gaeltacht.shp') tm_shape(cty) + tm_fill(col="PCVAC20111",title='% Vacant Houses',style='jenks') + tm_borders() + tm_shape(gael) + tm_fill(col='darkblue',alpha=0.6) -> cmap cmap + tm_view(basemaps = c("OpenStreetMap.BlackAndWhite","Stamen.Watercolor"), alpha=0.5)