get_asp_ratio: Get aspect ratio

Description Usage Arguments Details Value Examples

View source: R/get_asp_ratio.R

Description

Get the aspect ratio of a shape object, a tmap object, or a bounding box

Usage

1
get_asp_ratio(x, is.projected = NA, width = 700, height = 700, res = 100)

Arguments

x

A shape from class sf, stars, sp, or Raster, a bounding box (that can be coerced by bb), or a tmap object.

is.projected

Logical that determined wether the coordinates of x are projected (TRUE) or longitude latitude coordinates (FALSE). By deafult, it is determined by the coordinates of x.

width

See details; only applicable if x is a tmap object.

height

See details; only applicable if x is a tmap object.

res

See details; only applicable if x is a tmap object.

Details

The arguments width, height, and res are passed on to png. If x is a tmap object, a temporarily png image is created to calculate the aspect ratio of a tmap object. The default size of this image is 700 by 700 pixels at 100 dpi.

Value

aspect ratio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
if (require(tmap) && packageVersion("tmap") >= "2.0") {
    data(World)

    get_asp_ratio(World)

    get_asp_ratio(bb(World))

    tm <- qtm(World)
    get_asp_ratio(tm)
}

## Not run: 
    get_asp_ratio("Germany") #note: bb("Germany") uses geocode_OSM("Germany")

## End(Not run)

tmaptools documentation built on Jan. 20, 2021, 1:07 a.m.