1

Pick a city of the world to your liking and retrieve its bounding box. Then plot it: What do you see?
The function you may search for is part of the data package. Have a look at the slides.
boothbay <- osmdata::getbb("Boothbay")

plot(boothbay)

# We see two points, which build the extremes of the bounding box.

2

Please choose a couple of building types you are interested in and set them as key and value pairs. You can find a list of building types in the Overpass API documentation. But don’t forget to set the timeout query parameters using the osmdata::opq() function first.
First, specify the bounding box like before; second, the query parameters; and third, the key and value pairs. Try using a pipe workflow, as it makes it easier.
boothbay <-
  osmdata::getbb("Boothbay") |>  
  osmdata::opq(timeout = 25*100) |> 
  osmdata::add_osm_feature(
    key = "building", 
    value = c("house", "residential", "apartments", "detached", "bungalow")
  )

3

Download the data using the osmadata::osmdata_sf() function and extract only the polygons.
The downloaded data is a list. The polygons are a named list element that you can extract with its name osm_polygons, just like a variable in a data table.
boothbay <-
  osmdata::getbb("Boothbay") |>  
  osmdata::opq(timeout = 25*100) |> 
  osmdata::add_osm_feature(
    key = "building", 
  ) |> 
  osmdata::osmdata_sf()

boothbay <- boothbay$osm_polygons

4

Take some time to browse through the data. Depending on your chosen building type, you may find some interesting information. You can also plot the data you have just downloaded.
You may consider converting the data into a tibble using tibble::as_tibble() and maybe a sf::st_as_sf() afterward for a nicer browsing experience.
library(tmap)

boothbay <-
  boothbay |> 
  tibble::as_tibble() |> 
  sf::st_as_sf()

boothbay
## Simple feature collection with 2232 features and 86 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -69.69212 ymin: 43.7545 xmax: -69.51428 ymax: 43.94156
## Geodetic CRS:  WGS 84
## # A tibble: 2,232 × 87
##    osm_id    name    `addr:city` `addr:county` `addr:hamlet` `addr:housenumber` `addr:locality` `addr:postcode` `addr:state` `addr:street`
##    <chr>     <chr>   <chr>       <chr>         <chr>         <chr>              <chr>           <chr>           <chr>        <chr>        
##  1 234813057 <NA>    <NA>        <NA>          <NA>          <NA>               <NA>            <NA>            <NA>         <NA>         
##  2 234813059 <NA>    <NA>        <NA>          <NA>          <NA>               <NA>            <NA>            <NA>         <NA>         
##  3 234813061 <NA>    <NA>        <NA>          <NA>          <NA>               <NA>            <NA>            <NA>         <NA>         
##  4 234813064 <NA>    <NA>        <NA>          <NA>          <NA>               <NA>            <NA>            <NA>         <NA>         
##  5 235324281 Southp… Southport   <NA>          <NA>          1032               <NA>            04576           <NA>         Hendricks Hi…
##  6 235324664 Robins… Southport   <NA>          <NA>          20                 <NA>            04576           ME           Hendricks Hi…
##  7 235326155 Southp… Southport   <NA>          <NA>          443                <NA>            04576           <NA>         Hendricks Hi…
##  8 307439615 <NA>    Boothbay    <NA>          <NA>          92                 <NA>            04537           ME           Isle of Spri…
##  9 307439616 <NA>    Boothbay    <NA>          <NA>          96                 <NA>            04537           ME           Isle of Spri…
## 10 307439617 <NA>    Boothbay    <NA>          <NA>          60                 <NA>            04537           ME           Isle of Spri…
## # ℹ 2,222 more rows
## # ℹ 77 more variables: `addr:unit` <chr>, amenity <chr>, area <chr>, barrier <chr>, beauty <chr>, brand <chr>, `brand:wikidata` <chr>,
## #   building <chr>, `building:colour` <chr>, `building:levels` <chr>, `building:material` <chr>, check_date <chr>, club <chr>,
## #   company <chr>, craft <chr>, cuisine <chr>, denomination <chr>, description <chr>, ele <chr>, emergency <chr>, `fuel:diesel` <chr>,
## #   `fuel:octane_89` <chr>, `gnis:county_id` <chr>, `gnis:created` <chr>, `gnis:feature_id` <chr>, `gnis:state_id` <chr>, golf <chr>,
## #   guest_house <chr>, healthcare <chr>, `healthcare:speciality` <chr>, heritage <chr>, `heritage:operator` <chr>,
## #   `heritage:website` <chr>, historic <chr>, house <chr>, information <chr>, layer <chr>, leisure <chr>, lit <chr>, man_made <chr>, …
tmap_mode(("view"))
## tmap mode set to interactive viewing
tm_shape(boothbay) +
  tm_polygons()