Learn R Programming

futureheatwaves (version 1.0.3)

closest_point: Find closest grid point to a city location

Description

This function identifies the closest grid points in a climate model to a city based on the city's latitude and longitude using the Euclidean distance.

Usage

closest_point(city, latlong)

Arguments

city
A numeric vector containing the city's ID, latitude, and longitude, in that order.
latlong
A dataframe of latitude and longitude of each climate grid cell, with latitudes in the first column and longitudes in the second column. The readLatLong function re-orders the columns of longitude and latitude to comply with this format if necessary.

Value

An index corresponding to the column in the climate projections dataframe for that climate model that is closest to the city's coordinates.