knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(windfetch)
Wind fetch is an important measurement in coastal applications. It provides a measurement for the unobstructed length of water over which wind from a certain direction can blow over. The higher the wind fetch from a certain direction, the more energy is imparted onto the surface of the water resulting in a larger sea state. Therefore, the larger the fetch, the larger the exposure to wind and the more likely the site experiences larger sea states.
Averaging the wind fetch for numerous directions at the same location is a reasonable measure of the overall wind exposure. The process of manually calculating wind fetch can be extremely time-consuming and tedious, particularly if a large number of fetch vectors are required at many locations. The windfetch package calculates wind fetch for any marine location on Earth. There are also plot methods to help visualise the wind exposure at the various locations, and the ability to output the fetch vectors to a shape file for further investigation.
You can install and load the latest version of windfetch from GitHub.
if (!require(remotes)) install.packages("remotes") # Install windfetch remotes::install_github("blasee/windfetch")
# Load the windfetch and sf package library(windfetch) library(sf) # Read a shapefile of the North Carolina coastline nc = st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) # Create an sf geometry ncg = st_geometry(nc) # Project the coastline using the NAD83 projection nc_proj = st_transform(ncg, "epsg:32119") # Create a dataframe of the sites to calculate wind fetch at sites_df = data.frame(lon = c(-76, -76, -77.3), lat = c(36, 35.3, 34.5)) # Include spatial reference information by transforming to an sf object sites_points = st_as_sf(sites_df, coords = c("lon", "lat"), crs = "epsg:4326") # Project the points onto the same projection as the coastline sites_points_proj = st_transform(sites_points, "epsg:32119")
If you already have an sf
polygon object representing the coastline and
surrounding islands, and an sf
points object representing the locations,
then calculating wind fetch with windfetch is easy. You can just pass these
two arguments into the windfetch()
function.
plot(ncg, col = "lightgrey", border = "grey") plot(sites_points, pch = "x", add = TRUE) text(st_coordinates(sites_points), labels = paste("Site", 1:3), pos = 3)
# Calculate wind fetch by passing in the projected sf polygons object (nc_proj) # and the projected points object (sites_points_proj) to the windfetch function. my_fetch_proj = windfetch(nc_proj, sites_points_proj, progress_bar = FALSE) summary(my_fetch_proj)
The my_fetch_proj
object provides a summary of the fetch for all the four
quadrants, along with an average of the fetch length at all the sites.
# Plot the fetch vectors and the coastline in the projected space plot(my_fetch_proj, axes = TRUE) plot(nc_proj, col = "lightgrey", border = "grey", add = TRUE)
# Transform the CRS back to lats and longs my_fetch_latlon = crs_transform(my_fetch_proj, "epsg:4326") # Plot the fetch vectors and the coastline in lat lon space plot(my_fetch_latlon, axes = TRUE) plot(ncg, col = "lightgrey", border = "grey", add = TRUE)
# Transform the fetch object to an sf object my_fetch_sf = as_sf(my_fetch_latlon) my_fetch_sf
# Export the fetch vectors to an ESRI shape file for further investigation st_write(nc_fetch_sf, "nc_fetch.shp", driver = "ESRI Shapefile")
Read the short introductory vignette to get you started with windfetch, and
have a look at the simple, reproducible example in the windfetch()
function.
# A simple reproducible example example(windfetch)
Please refer to the Data Access Portal entry at CSIRO for the citation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.