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

Xiang Ye x|@ngye @end|ng |rom bu||@|o@edu
Thu Feb 29 06:58:56 CET 2024


Thank you, Prof. Pebesma, for confirming my guess!

Have a great day.

叶翔 YE, Xiang
THINKING SPATIALLY<http://www.linkedin.com/in/spatialyexiang>.
Ph.D. in Spatial Statistics
________________________________
From: Edzer Pebesma <edzer.pebesma using uni-muenster.de>
Sent: Wednesday, February 28, 2024 17:02
To: Xiang Ye <xiangye using buffalo.edu>; R Special Interest Group on using Geographical data and Mapping <r-sig-geo using r-project.org>
Subject: Re: [R-sig-Geo] Unit of parameters in the expandBB argument

[You don't often get email from edzer.pebesma using uni-muenster.de. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

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://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr.geocompx.org%2Fspatial-class%23%3A~%3Atext%3Dto%2520geographic%2520data.-%2CexpandBB%2C-%252C%2520for%2520example%252C%2520can&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521200682%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=gd0V68L7p31unY28JZm0TZUjRB9uNHX6OA%2BCnbrWcWk%3D&reserved=0<https://r.geocompx.org/spatial-class#:~:text=to%20geographic%20data.-,expandBB,-%2C%20for%20example%2C%20can>
> [https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr.geocompx.org%2Fimages%2Fcover.png&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521207402%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=v%2FAr5z6tr4GVgKCVLx3utqwM38cNFmSjX4AoFTMaudY%3D&reserved=0]<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr.geocompx.org%2Fspatial-class%23%3A~%3Atext%3Dto%2520geographic%2520data.-%2CexpandBB%2C-%252C%2520for%2520example%252C%2520can&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521210525%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=pO0h5F7SVp%2BHAtfNwpfpxOyX%2F92osjKlsYe558ApIXA%3D&reserved=0<https://r.geocompx.org/images/cover.png>>
> Chapter 2 Geographic data in R | Geocomputation with R<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr.geocompx.org%2Fspatial-class%23%3A~%3Atext%3Dto%2520geographic%2520data.-%2CexpandBB%2C-%252C%2520for%2520example%252C%2520can&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521214053%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=3R5elU4T6D5XXq92g36j%2B9kxrUwtky9yMLwxWgttcKU%3D&reserved=0<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://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr-spatial.github.io%2Fsf%2Freference%2Fplot.html%23%3A~%3Atext%3Dfractional%2520values%2520to%2520expand%2520the%2520bounding%2520box%2520with&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521217634%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=%2BGoDxw4m4RTDboRGEh0L9FM5bjtLTic1%2FJdFAUL%2F4I8%3D&reserved=0<https://r-spatial.github.io/sf/reference/plot.html#:~:text=fractional%20values%20to%20expand%20the%20bounding%20box%20with>
> [https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr-spatial.github.io%2Fsf%2Flogo.png&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521221647%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=0bVJZve69U01ahr7GzwghQ3A0pCzVBYLZH0A0YRzXzk%3D&reserved=0]<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr-spatial.github.io%2Fsf%2Freference%2Fplot.html%23%3A~%3Atext%3Dfractional%2520values%2520to%2520expand%2520the%2520bounding%2520box%2520with&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521225251%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=1iOiKsbSvEyGaM%2FnA6mia5UtIoj%2FfYlRHwvdZI1PyEA%3D&reserved=0<https://r-spatial.github.io/sf/logo.png>>
> plot sf object �� plot<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fr-spatial.github.io%2Fsf%2Freference%2Fplot.html%23%3A~%3Atext%3Dfractional%2520values%2520to%2520expand%2520the%2520bounding%2520box%2520with&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521229054%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=sVWlFm8SBWMb8rP4HFebS9S2iH7C21YoTVfPxYjeUPk%3D&reserved=0<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<https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fspatialyexiang&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521233419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=TrtdJuTBUTI8MaBhvgAHM9tebXux4H8miclYlrCOBDk%3D&reserved=0<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://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=05%7C02%7Cxiangye%40buffalo.edu%7Cb5cdaf1352f842a7248f08dc383bfe0a%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447077521237401%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=wOnccBlOIOuHjDu8Hwy1f42W7PkOEWChQP8NypjL6Dw%3D&reserved=0<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

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list