Open mdsumner opened 5 years ago
Take raw arrays from ROMS, map them as raster "index grids" and regrid with interpolation (or lookup any points). salt_200.zip
salt<-"salt_200.mat" library(rmatio) s <- rmatio::read.mat(salt) library(quadmesh) library(raster) cd <- t(flip(brick(raster(s$lon), raster(s$lat)), "x")) cd <- setExtent(cd, extent(0, ncol(cd), 0, nrow(cd))) saltraster <- flip(raster(t(s$salt_200)), "y") saltraster <- setExtent(saltraster, extent(0, ncol(saltraster), 0, nrow(saltraster))) mesh_plot(saltraster, coords = cd, crs = "+proj=stere +lat_0=-90 +lon_0=100 +datum=WGS84") library(angstroms) r <- raster(extent(77, 95, -66, -55), res = 1, crs = "+proj=longlat +datum=WGS84") xy <- romsmap(SpatialPointsDataFrame(coordinates(r, sp = TRUE), data.frame(a = 1:ncell(r))), cd) plot(saltraster) points(xy, pch = ".") plot(setValues(r, raster::extract(saltraster, xy), method = "bilinear"))
Take raw arrays from ROMS, map them as raster "index grids" and regrid with interpolation (or lookup any points). salt_200.zip