Create line geometries representing fetch rays from each site. Useful for detailed visualization of the ray-casting results.
Arguments
- fetch_data
Results from
fetch_calculate
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 <- 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: HTTP 504 Gateway Timeout.
#> Querying natural=water...
#> Error: arguments imply differing number of rows: 1160, 0
#> Server error, trying another server in 6s...
#> Failed after 3 attempts: HTTP 504 Gateway Timeout.
#> 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
results <- fetch_calculate(sites, lake)
#> Effective fetch method: top3
#> Using default depth: 10 m
#> Assigning sites to lakes...
#> Checking direct intersections...
#> 2 sites matched directly
#> Site assignment summary:
#> Matched: 2/2
#> Sites per lake:
#> Approximate Boundary: 2 sites
#> Calculating fetch for multiple lakes...
#> Buffering sites 10m inward
#> Angle resolution: 5 degrees
#> Processing 1 lake(s)...
#> Using sequential processing
#> Processing 2 samples in lake: Approximate Boundary
#> Fetch calculation complete.
#> Adding lake context (NHD integration)...
#> Fetching NHD waterbodies...
#> Found 68 NHD waterbodies
#> Processing lake: fallback
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Found 7 outlet(s) and 4 inlet(s)
#> Warning: st_centroid assumes attributes are constant over geometries
#> Lake context complete.
rays <- create_ray_geometries(results)
# Plot rays for a specific site
site_name <- results$results$Site[1]
site_rays <- rays[rays$Site == site_name, ]
ggplot2::ggplot() + ggplot2::geom_sf(data = site_rays, ggplot2::aes(color = Distance))
# }
