knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
morphogram
r packageVersion("morphogram")
r ifelse(packageVersion("morphogram")<="1.0.0","(beta)","")
.r Sys.Date()
.This R-package is designed to facilitate the construction of "morphogram"-based infographics which place dispersed spatial features side-by-side, for example to compare visually the shapes or dimensions of cities, study regions or building sizes in two dimensional space. The package aims to preserve recognisable or accurate shapes (and by default, the linear dimensions) of the features to allow human recognition, but transpose their spatial position so that they are distributed in a visually understandable way. When spatial dimensions are preserved, further spatial analysis (e.g. area calculations) or the additional of scale bars can be accurately plotted.
Functions rely on sf
objects as inputs and outputs, hence the primary dependency of this package is sf
. The use of sf
objects provides maximum flexibility for ultimate graphics output; users can use base graphics or alternatives such as ggplot2
according to need or preference, using the resulting reprojected and translated sf
features produced.
Although theoretically any sf
-compatible spatial features can be processed with this package, the most likely application is the orientation of polygons in a way that their relative size can be easily compared.
The original design use-case was archaeological, namely the visualization of the relative size of study regions of different archaeological surveys, ancient theatre plans and the relative dimensions of ancient cities.
This package relies on the sf
package for calculating geometries and handling spatial data. Depending on the platform you are using, you may need to install GDAL and other dependencies before using sf
and morphogram
. Read the sf
documentation for more information: see sf README on GitHub.
You can install the current development version of morphogram
from GitHub with:
# install.packages("devtools") devtools::install_github("tcwilkinson/morphogram")
This example shows you how to converge, distribute and then plot a set of simple (spatial) features using data distributed with the sf
package, North Carolina district, as a regular grid:
library(sf) library(morphogram) # load polygon data from the sf package nc <- sf::st_read(system.file("shape/nc.shp", package="sf"),quiet=T) # converge polygons around origin nc_converged <- converge(nc,by.feature=T) # distribute polygons into regular grid nc_distributed <- distribute(nc_converged, margin=1, x.mar=2) # plot resulting distributed features # optional: select first parameter in data.frame, this is just for clarity of the final plot nc_d <- nc_distributed[1] # AREA plot(nc_d)
Read the vignette for guidance on how to get started using morphogram and further examples:
browseVignettes("morphogram")
...or browse the online version of the package documentation and vignette: https://tcwilkinson.github.io/morphogram/
Do let me know if you use this package in any publications, I'd be pleased to link to them here.
For ideas and plans on how to improve this package in the future, see the TODO.md file.
Pull requests on this package which improve the documentation, methods or examples are welcome.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.