Skip to content
Prev 27163 / 29559 Next

Plotting x and y values using data from two separate netCDF files in R

I would try for a single point:

x <- raster::brick(ncfname, varname = "cum_co2_emi-CanESM2")
y <- raster::brick(ncfname1, varname = "onedaymax")

pt <- cbind(30, -5)
to_plot <- cbind(raster::extract(x, pt), raster::extract(y, pt))

plot(to_plot)

Is that close?  You might be better off using raster::as.data.frame(x, xy =
TRUE, long = TRUE) if you want all locations at their actual centre.

See if the times of the 3rd axis are valid (and the same) in getZ(x) and
getZ(y).

There's rarely a need to use ncdf4 directly, though that's important
sometimes, more so for grids that raster's regular-affine referencing model
doesn't support.

cheers, Mike



On Wed, 27 Mar 2019 at 05:29 rain1290--- via R-sig-Geo <
r-sig-geo at r-project.org> wrote: