stationFromCoords: Identify GSOD stations in the vicinity of a given geographic...

View source: R/stationFromCoords.R

stationFromCoordsR Documentation

Identify GSOD stations in the vicinity of a given geographic location

Description

This function allows the selection of a subset of GSOD stations based on a specified location and a desired buffer size.

Usage

stationFromCoords(x, y = NULL, width = 50, ...)

Arguments

x

Numeric. A a single number specifying the x (longitude) coordinate, or a vector of two numbers specifying the x and y (latitude) coordinate, or an object of class SpatialPoints.

y

Numeric, default is NULL. A single number specifying the y coordinate. Note: if a vector of two numbers is supplied to the previous argument, this parameter will automatically be ignored.

width

Numeric, default is 50. The desired buffer width (km) that will be applied to the specified coordinate.

...

Additional arguments passed to round.

Value

A sf object.

Author(s)

Florian Detsch

See Also

geodist

Examples

# Identify GSOD stations that lie within a distance of 100 km around Kibo summit
gsod_shp <- stationFromCoords(x = 37.359031, 
                              y = -3.065053, 
                              width = 100)

rworldmap::mapGriddedData(mapRegion = "africa", plotData = FALSE, borderCol = "black", 
               addLegend = FALSE)
points(sf::st_coordinates(gsod_shp), col = "red", pch = 20, cex = 2)
 
# Alternatively
gsod_shp <- stationFromCoords(x = c(37.359031, -3.065053), 
                              width = 100)

# Alternatively
kibo = sf::st_as_sf(
  data.frame(
    x = 37.359031
    , y = -3.065053
  )
  , crs = 4326
  , coords = c("x", "y")
)

gsod_shp <- stationFromCoords(x = kibo, 
                              width = 100)


environmentalinformatics-marburg/GSODTools documentation built on Jan. 5, 2024, 12:19 a.m.