Get lake boundary polygon(s) either from OpenStreetMap or from a local file.
Value
A list with elements:
- all_lakes
sf object with lake polygons in UTM projection
- sites
sf object with site points in UTM projection
- utm_epsg
EPSG code for the UTM projection used
Details
If file is provided, the lake boundary is loaded from the file.
Otherwise, the function downloads lake boundaries from OpenStreetMap
based on the bounding box of the provided sites.
Examples
# \donttest{
csv_path <- system.file("extdata", "sample_sites.csv", package = "lakefetch")
sites <- load_sites(csv_path)
#> Loading data from: /github/home/R/x86_64-pc-linux-gnu-library/4.6/lakefetch/extdata/sample_sites.csv
#> Loaded 2 rows with columns: Site, latitude, longitude, lake.name
#> Using columns: Latitude = latitude, Longitude = longitude
#> Preserved lake name column: lake.name
#> Final valid samples: 2
#> Detected location from column 'lake.name': Blue Mountain Lake
lake_data <- get_lake_boundary(sites)
#> Converting to spatial format...
#> Spherical geometry (s2) switched off
#> Downloading lake boundaries from OpenStreetMap...
#> Bounding box: [-74.4561, 43.8545, -74.4304, 43.8751]
#> Trying name-filtered query for: Blue Mountain Lake
#> Error: arguments imply differing number of rows: 1160, 0
#> Server error, trying another server in 10s...
#> Failed after 3 attempts: arguments imply differing number of rows: 1160, 0
#> Querying natural=water...
#> Error: arguments imply differing number of rows: 1160, 0
#> Server error, trying another server in 6s...
#> Failed after 3 attempts: arguments imply differing number of rows: 1160, 0
#> Querying water=lake...
#> Error: arguments imply differing number of rows: 1160, 0
#> Server error, trying another server in 6s...
#> Failed after 3 attempts: arguments imply differing number of rows: 1160, 0
#> Warning: No water bodies found in OpenStreetMap - creating approximate boundary
#> Spherical geometry (s2) switched on
# }
