[R-sig-Geo] Unit of parameters in the expandBB argument

Xiang Ye x|@ngye @end|ng |rom bu||@|o@edu
Wed Feb 28 06:04:53 CET 2024


Dear community,

I recently revisited the expandBB argument in the plot() function for sf objects. It conveys a numeric vector of length 4 to expand the default canvas (in the order of bottom, left, top, right) when drawing an sf object. A quick refresh is here:

https://r.geocompx.org/spatial-class#:~:text=to%20geographic%20data.-,expandBB,-%2C%20for%20example%2C%20can
[https://r.geocompx.org/images/cover.png]<https://r.geocompx.org/spatial-class#:~:text=to%20geographic%20data.-,expandBB,-%2C%20for%20example%2C%20can>
Chapter 2 Geographic data in R | Geocomputation with R<https://r.geocompx.org/spatial-class#:~:text=to%20geographic%20data.-,expandBB,-%2C%20for%20example%2C%20can>
Prerequisites This is the first practical chapter of the book, and therefore it comes with some software requirements. You need access to a computer with a recent version of R installed (R 4.3.2...
r.geocompx.org

I am curious about the unit for the four values of the expandBB argument. In the help document, it only says the values are "fraction values to expand the bounding box with":

https://r-spatial.github.io/sf/reference/plot.html#:~:text=fractional%20values%20to%20expand%20the%20bounding%20box%20with
[https://r-spatial.github.io/sf/logo.png]<https://r-spatial.github.io/sf/reference/plot.html#:~:text=fractional%20values%20to%20expand%20the%20bounding%20box%20with>
plot sf object �� plot<https://r-spatial.github.io/sf/reference/plot.html#:~:text=fractional%20values%20to%20expand%20the%20bounding%20box%20with>
plot one or more attributes of an sf object on a map Plot sf object
r-spatial.github.io

However, it did not explicitly mention the unit adopted for the values.

My guess:
For the 1st and 3rd values in the argument, the unit is the height of the bounding box of the sf object; therefore a value of 0.2 expands (downward and upward, respectively) the canvas by 20% of the height of the bounding box.
For the 2nd and 4th values in the argument, the unit is the width of the bounding box of the sf object; therefore a value of 0.2 expands (leftward and rightward, respectively) the canvas by 20% of the width of the bounding box.

Is my understanding correct?

Thank you in advance!

Ҷ�� YE, Xiang
THINKING SPATIALLY<http://www.linkedin.com/in/spatialyexiang>.
Ph.D. in Spatial Statistics

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list