Learn R Programming

angstroms (version 0.0.1)

romsmap: Remap an object to the ROMS grid.

Description

Find the nearest-neighbour coordinates of x in the coordinate arrays of coords.

Usage

romsmap(x, ...)

# S3 method for SpatialPolygonsDataFrame romsmap(x, coords, crop = FALSE, lonlat = TRUE, ...)

# S3 method for SpatialLinesDataFrame romsmap(x, coords, crop = FALSE, lonlat = TRUE, ...)

# S3 method for SpatialPointsDataFrame romsmap(x, coords, crop = FALSE, lonlat = TRUE, ...)

Arguments

x
object to transform to the grid space, e.g. a Spatial object
...
unused
coords
romscoords RasterStack
crop
logical, if TRUE crop x to the extent of the boundary of the values in coords
lonlat
logical, if TRUE check for need to back-transform to longitude/latitude and do it

Value

input object with coordinates transformed to space of the coords

Details

The input coords is a assumed to be a 2-layer RasterStack or RasterBrick and using nabor::knn the nearest matching position of the coordinates of x is found in the grid space of coords. The motivating use-case is the curvilinear longitude and latitude arrays of ROMS model output.

No account is made for the details of a ROMS cell, though this may be included in future. We tested only with the "lon_u" and "lat_u" arrays.

Examples

Run this code
ant_ice_coords <- romsmap(antarctica, ice_coords)
plot(ice_fake, main = "sea ice in pure grid space")
plot(ant_ice_coords, add = TRUE)


Run the code above in your browser using DataLab