Package 'birdseyeview'

Title: Make Planning Maps, Tables, and Visualizations
Description: This package helps create maps, tables, and figures for planning documents using open spatial data. birdseyeview is designed to work with the sfext and maplayer packages and relies on sf, ggplot2, and gt.
Authors: Eli Pousson [aut, cre]
Maintainer: Eli Pousson <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-09 03:22:51 UTC
Source: https://github.com/elipousson/birdseyeview

Help Index


Merge and stack text from two columns in gt (variation on {gtExtras})

Description

A variation on the gtExtras::gt_merge_stack function that implements a horizontal rule parameter separating the top and bottom text and simplifies the requirements for the input variables. {gtExtras} was created by Thomas Mock and is available under an MIT License.

Usage

gt_merge_stack(
  gt_object,
  columns = c(1, 2),
  font_color = c("black", "grey"),
  ...,
  small_cap = FALSE,
  font_size = c(14, 10),
  font_weight = "bold",
  h_rule = FALSE
)

Arguments

gt_object

An existing gt table object of class gt_tbl

columns

Columns to stack, Default: c(1, 2)

font_color

Color(s) to use for stacked text. Default: c("black", "grey")

...

Arguments passed on to scales::col2hcl

h

Hue, ⁠[0, 360]⁠

c

Chroma, ⁠[0, 100]⁠

l

Luminance, ⁠[0, 100]⁠

alpha

Alpha, ⁠[0, 1]⁠.

small_cap

a logical indicating whether to use 'small-cap' on the top line of text

font_size

a string of length 2 indicating the font-size in px of the top and bottom text

font_weight

a string of length 2 indicating the 'font-weight' of the top and bottom text. Must be one of 'bold', 'normal', 'lighter'

h_rule

Horizontal rule to separate top and bottom column text. If TRUE, use a 1px line with a 2px margin on top and bottom. If FALSE, include no horizontal rule. To create a custom rule, provide a ⁠<hr>⁠ thematic break tag or a ⁠<div>⁠ with css styling.


Add maps of simple features into rows of a gt table

Description

Add maps of simple features into rows of a gt table with ggplot2. Function naming convention borrowed from gtExtras::gt_img_rows. Previously named gt_geom_sf_rows.

Usage

gt_sf_rows(
  gt_object,
  mapping = NULL,
  fill = NA,
  color = "black",
  size = 1,
  linetype = "solid",
  height = 100,
  asp = 1,
  geom = "sf",
  layer_fn = NULL,
  sf_label = "map",
  ...
)

Arguments

gt_object

An existing gt table object of class gt_tbl or an sf object. If a gt_object must be convertible to an sf object with sf::st_as_sf() (e.g. geometry must be retained before passing to gt::gt()).

mapping

aesthetic mapping passed to maplayer::layer_location_data(), Default: NULL

fill

Fill (used for polygon geometry), Default: NA

color

Color (used for polygon, point, and line geometry), Default: 'black'

size

Color (used for polygon, point, and line geometry), Default: 1

linetype

Color (used for polygon and line geometry), Default: 'solid'

height

The absolute height (px) of the map in the table cell

asp

The aspect ratio of the map in the table cell.

layer_fn

Optional rowwise function that results in ggplot2 map the replaces geometry column.

sf_label

Label used for column with ggplot2 map.


Make a key for a marker map

Description

Designed for use with maps created using layer_show_markers()

Usage

tbl_marker_key(
  data,
  title_col = NULL,
  groupname_col = NULL,
  number_col = NULL,
  color = FALSE,
  palette = NULL
)

Arguments

data

Data frame or sf object with marker data

title_col

Title column name, Default: NULL

groupname_col

Group column name, Default: NULL

number_col

Number column name, Default: NULL. If NULL and data does not contain a column named "number", add a number column created using dplyr::row_number() function.

color

If TRUE, apply a cell fill color to the group headings in the table (defined by groupname_col)

palette

palette to use for the group heading fill colors (passed to group_data_pal())


Create numbered photo key as a gt table (not working)

Description

Designed to work with the sfext::read_sf_exif function. More information on this approach here https://elipousson.github.io/posts/2021-03-06-creating-a-key-map-for-photographs-with-r/

Usage

tbl_photo_key(
  data,
  height = 240,
  asp = 0.75,
  photo_col = "photo",
  title_col = "title",
  title_size = "large",
  title_align = "right",
  number = FALSE,
  orientation = NULL
)

Arguments

data

sf object or data frame with photo column containing the file path or url for photos.

height

The height in pixels of image in table.

asp

Aspect ratio of image (width/height)

photo_col

Photo path/url column name.

title_col

Title/description column name.

title_size

Title text size, Default: 'large'

title_align

Title tex alignment, Default: 'right'

number

If TRUE, add a number column that will by 20% of the width of the photo column; defaults to FALSE. There may be a name conflict if the dataframe already contains a column named "rowid".

orientation

Orientation to filter by if data contains image_width and image_height columns.

Details

Function naming convention inspired by the gtsummary package https://www.danieldsjoberg.com/gtsummary/index.html