Thank you, Prof. Bivand, for providing the rich background information!
Now I think I know the full meaning of expandBB argument and how it will be 
utilized.

Have a nice day!

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

[You don't often get email from roger.biv...@nhh.no. Learn why this is 
important at https://aka.ms/LearnAboutSenderIdentification ]

On Wed, 28 Feb 2024, Edzer Pebesma wrote:

>
>
> 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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436494240%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=9mPCsXC9OJmIWzCf%2FUUj%2F9kVXB7fScooNV3nnofyyR0%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436504367%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=BTMXaApFbzOb231GtsPPEedq%2BpiSkpwfTb1LoZXEeC4%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436507620%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=Kb%2FMI9jD9DIwW1rZxqRHGssWsJxjN%2Bf5oDzlcPRpKOE%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436511220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=nM15KyHxbi0c%2BxahVzKS%2F0vAlZhhYjP0Iva907VuBWk%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436514796%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=KgfpOFFs7EQXNPLjKLcW3GtOc%2F0r%2FswXb%2Brbif6qGJE%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436518817%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=ZsT1c7odJ9FB6qmaqPfVFyZhkO6EsrOHkj15tCvJNM8%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436522289%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=L3VssOMWHPbgNUijN5%2FsyRXaWXAuMzmYI9ySa9hviKk%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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436526336%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=IN5OYubYPs%2BmOGD1UUEHGL6r5K5NZjFjlIP9y1AMDOs%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.
>

The code is at:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fr-spatial%2Fsf%2Fblob%2Fbd1940f68dd7607b7e9098ccc32c99e273c30a60%2FR%2Fplot.R%23L598-L611&data=05%7C02%7Cxiangye%40buffalo.edu%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436530190%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=SiwXVVpYV3O%2BCWP%2F4DT98xMFGnmfCLvdUq341GWR4sk%3D&reserved=0<https://github.com/r-spatial/sf/blob/bd1940f68dd7607b7e9098ccc32c99e273c30a60/R/plot.R#L598-L611>

based on the equivalent in sp:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fedzer%2Fsp%2Fblob%2Fe60dedf3ff3d06d9ebd9d38818b072e4475758cf%2FR%2FSpatial-methods.R%23L211-L226&data=05%7C02%7Cxiangye%40buffalo.edu%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436533591%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=%2BVuCUgoCaoADfovzTjdHnZYuM4QD5OW85oq7nZ1Z53Y%3D&reserved=0<https://github.com/edzer/sp/blob/e60dedf3ff3d06d9ebd9d38818b072e4475758cf/R/Spatial-methods.R#L211-L226>

and added in a commit 8 years ago:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fedzer%2Fsp%2Fcommit%2Fd65045951bfebf28fbd5d0ad56bfff3cb48d57a8&data=05%7C02%7Cxiangye%40buffalo.edu%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436537065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=7SY%2BG0%2BlcF%2B7vOMyNU46Og94SZkAQFspogFDuzYfWes%3D&reserved=0<https://github.com/edzer/sp/commit/d65045951bfebf28fbd5d0ad56bfff3cb48d57a8>.

So the units are implicitly those of sp::bbox() and sf::st_bbox().

Roger



>>
>>  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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436540071%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=TL1T70IUgYhJJnLe9f17toJHto%2Fnpp%2BopAGNhtMTsko%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@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%7C53345ace32a448abcb5208dc38414ee2%7C96464a8af8ed40b199e25f6b50a20250%7C0%7C0%7C638447100436543135%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=YcS%2FqltAQTu%2Bx7xMiZ0%2Bsd3veSQWa39%2Fi5KwKgWyTL0%3D&reserved=0<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>
>

--
Roger Bivand
Emeritus Professor
Department of Economics, Norwegian School of Economics,
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
e-mail: roger.biv...@nhh.no

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to