
cf. https://mhweber.github.io/AWRA_2020_R_Spatial

```{r}
library(tmap)
library(tmaptools)
library(dplyr)

gr <-tmaptools::geocode_OSM("Grand Rapids", 
        as.sf = TRUE) %>% 
  glimpse()

gr %>%
  ggplot() +
  geom_sf()
```

```{r}
library(sf)
library(tigris)

counties <- counties("Michigan", cb = TRUE)
counties$
counties$area <- as.numeric(st_area(counties))
glimpse(counties)

tm_shape(counties) +
  tm_polygons("area", 
              style="quantile", 
              title="Michigan Counties Area")

```

```{r}
library(mapview)
mapview(gr, col.regions = "red") + 
  mapview(counties, alpha.regions = 0.1)
```

```{r}
library(sf)
mi_water <- read_sf("data/michigan_water/michigan_water.shp")
glimpse(mi_water)
options(scipen=3)
plot(mi_water$geometry, axes=T, main='Michigan Bodies of Water') 
```

```{r}
library(osmdata)
library(mapview)

footway <- opq(bbox = "Grand Rapids") %>% 
  add_osm_feature(key = "highway", value = "footway") %>% 
  osmdata_sf()
footway <- footway$osm_lines
mapview(footway$geometry)
```

```{r}
library(osmdata)
library(mapview)
rstrnts <- opq(bbox = "Grand Rapids Michigan") %>% 
    add_osm_feature(key = "amenity", value = "restaurant") %>%
    osmdata_sf()
rstrnts <- rstrnts$osm_points

mapview(rstrnts$geometry)
```