Skip to contents

This function downloads GADM administrative boundary data for specified countries and performs a spatial join to add administrative information to a dataset containing geographic coordinates. Optionally, an sf object can be provided instead of downloading data.

Usage

spatial_join_gadm(
  country_codes = c("AUT", "BIH", "BGR", "CHE", "CZE", "DEU", "HUN", "HRV", "MDA", "MNE",
    "POL", "ROU", "SRB", "SVK", "SVN", "UKR"),
  coords_df,
  lat_col = "decimalLatitude",
  lon_col = "decimalLongitude",
  sf_gadm = NULL,
  timeout = 600
)

Arguments

country_codes

A character vector of ISO3 country codes for which GADM data will be downloaded. Defaults to the countries in the Danube River Basin.

coords_df

A data frame containing coordinates to spatially join with GADM administrative data. It must include columns for latitude and longitude.

lat_col

The name of the column in coords_df containing latitude values. Defaults to "decimalLatitude".

lon_col

The name of the column in coords_df containing longitude values. Defaults to "decimalLongitude".

sf_gadm

Optional sf object containing GADM administrative boundaries. If provided, it is used directly for the spatial join. Defaults to NULL.

timeout

Timeout in seconds for downloads. Defaults to 600 (10 minutes).

Value

A data frame with the same columns as the input coords_df, along with administrative attributes from the GADM data.