Learn R Programming

tmaptools (version 2.0-1)

get_asp_ratio: Get aspect ratio

Description

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

Usage

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

Arguments

x

shape object (either Spatial, a Raster, or an sf), 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.

Value

aspect ratio

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.

Examples

Run this code
# NOT RUN {
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")
# }

Run the code above in your browser using DataLab