[R-sig-Geo] Unit of parameters in the expandBB argument
Edzer Pebesma
edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Wed Feb 28 10:02:22 CET 2024
On 28/02/2024 06:04, Xiang Ye via R-sig-Geo wrote:
> 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?
Yes. It takes 4 values for each of the sides (bottom, left, top, right).
You can use xlim and ylim to set the plot region in spatial coordinates.
>
> Thank you in advance!
>
> Ҷ�� YE, Xiang
> THINKING SPATIALLY<http://www.linkedin.com/in/spatialyexiang>.
> Ph.D. in Spatial Statistics
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Edzer Pebesma (he/him)
Universität Münster, Institute for Geoinformatics
Heisenbergstrasse 2, 48149 Münster, Germany
Phone: +49 251 8333081
More information about the R-sig-Geo
mailing list