# utilities: Various utilities functions for AURELHY In aurelhy: Hydrometeorological interpolation

## Description

These functions manipulate geographical coordinates in various ways to optimize computation of the AURELHY method.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```deg.lat(latitude) deg.lon(latitude) polar.coords(geomat, x, y, maxdist) match.coords(points, table, tol = 0.002) coords(x, ...) resample(x, ...) add.points(x, ...) ## S3 method for class 'geomask' add.points(x, geopoints, ...) dist2sea(geotm) ```

## Arguments

 `latitude` the latitude in decimal degrees `geomat` a 'geomat' object `x` X coordinate of the reference point for `polar.coords()`, or a correct object for the other functions `y` Y coordinate of the reference point `maxdist` maximum distance to consider in km. All points whose distance from the reference point is larger are not considered in the calculation `points` a list or data frame with X and Y coordinates of the points to match to the reference points (in decimal degrees, for instance) `table` a similar list or data frame with X(ref) and Y(ref) coordinates of the reference points to be matched (in the same units as for `points`) `tol` the maximum tolerance in X and Y units to consider points are matching, that is, X +/- tol = X(ref) and Y +/- tol = Y(ref) `...` further arguments passed to the method `geopoints` a geopoints object from which we want to add corresponding points in a geomask `geotm` a geotm object

## Details

`deg.lat()` and `deg.lon()` provide the length of one degree in, respectively, latitude and longitude in km, given the corresponding latitude in decimal degrees. The ellipsoid defined in WGS84 model is used for these calculations. `polar.coords()` calculates polar coordinates of points. `match.coords()` selects points with matching coordinates, given a tolerance distance between the reference points (i.e., from a geotm grid, using `coords(my_geotm, "xy")`) and the points to match (stations). `coords()` is a generic function that extracts geographical coordinates from one object in different fashions. `resample` is a generic function to resample a grid ('geomat' object). `add.points` add points from a geopoints object in a geomask. `dist2sea()` calculate the distance of points in a geotm object to the sea.

## Value

`deg.lat()` and `deg.lon()` return the length of one degree in km. `polar.coords()` returns a data frame with 'angle' in rad and 'dist'(ance) in km for the reference point to each point in the grid, within 'maxdist'. There is also a 'geomat' attribute containing the window of the initial 'geomat' object containing the considered points.

`match.coords()` returns a vector of logical of the same length as the number of colunms in the points data frame (that must contain 'x' and 'y' columns with coordinates of points to be matched).

## Author(s)

Philippe Grosjean <[email protected]>, and Francois Delobel for `dist2sea()`

`geomat`, `auremask`
 ```1 2 3 4 5``` ```# Size of one degree in latitude and longitude, given the latitude in decimal degrees deg.lat(c(0, 15, 30, 45, 60, 75, 90)) # 110.574 110.649 110.852 111.132 111.412 111.618 111.694 deg.lon(c(0, 15, 30, 45, 60, 75, 90)) # 111.320 107.550 96.486 78.847 55.800 28.902 0.000 ```