Skip to main content
added 302 characters in body
Source Link

I have two data files. One of them contains locations with certain spots.

data_locs <- data.frame(
  Year = c(2000, 2001, 1993, 1993, 1994, 1995),
  Month = c(1, 1, 2, 9, 9, 9),
  Day = c(24, 22, 4, 9, 21, 27),
  Long = c(11.3667, 11.6167, -0.2833, -8.9848, -8.9833, -9.3048),
  Lat = c(57.6833, 57.5500, 60.0000, 42.2412, 42.2428, 41.9963),
  Depth = c(68, 29, 141, 99, 99, 170)
)

And on the other side I have a .nc file with data from Copernicus with some variables: temperature, salinity, ocean mix layer thickness. (I downloaded an example from (https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/descriptionCopernicus with reduced spatial and temporal extents that can be downloaded from )my github.

What I want to do is extract the values of the raster matching the date (year/month/day), location and depth the get the projected values of the variables. However, all examples I can find online are using ncvar_get to get grided values for latitude, longitude, etc. and then looking for closes locations instead of using the capabilities of the rasters.

It may be a problem of concept but isn't it better to use the projected? How do I extract the values of the locations in data_locs?

I have two data files. One of them contains locations with certain spots.

data_locs <- data.frame(
  Year = c(2000, 2001, 1993, 1993, 1994, 1995),
  Month = c(1, 1, 2, 9, 9, 9),
  Day = c(24, 22, 4, 9, 21, 27),
  Long = c(11.3667, 11.6167, -0.2833, -8.9848, -8.9833, -9.3048),
  Lat = c(57.6833, 57.5500, 60.0000, 42.2412, 42.2428, 41.9963),
  Depth = c(68, 29, 141, 99, 99, 170)
)

And on the other side I have a .nc file with data from Copernicus with some variables: temperature, salinity, ocean mix layer thickness. ( (https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description )

What I want to do is extract the values of the raster matching the date (year/month/day), location and depth the get the projected values of the variables. However, all examples I can find online are using ncvar_get to get grided values for latitude, longitude, etc. and then looking for closes locations instead of using the capabilities of the rasters.

It may be a problem of concept but isn't it better to use the projected? How do I extract the values of the locations in data_locs?

I have two data files. One of them contains locations with certain spots.

data_locs <- data.frame(
  Year = c(2000, 2001, 1993, 1993, 1994, 1995),
  Month = c(1, 1, 2, 9, 9, 9),
  Day = c(24, 22, 4, 9, 21, 27),
  Long = c(11.3667, 11.6167, -0.2833, -8.9848, -8.9833, -9.3048),
  Lat = c(57.6833, 57.5500, 60.0000, 42.2412, 42.2428, 41.9963),
  Depth = c(68, 29, 141, 99, 99, 170)
)

And on the other side I have a .nc file with data from Copernicus with some variables: temperature, salinity, ocean mix layer thickness. I downloaded an example from Copernicus with reduced spatial and temporal extents that can be downloaded from my github.

What I want to do is extract the values of the raster matching the date (year/month/day), location and depth the get the projected values of the variables. However, all examples I can find online are using ncvar_get to get grided values for latitude, longitude, etc. and then looking for closes locations instead of using the capabilities of the rasters.

It may be a problem of concept but isn't it better to use the projected? How do I extract the values of the locations in data_locs?

Source Link

Read a .nc file and get variables at certain locations

I have two data files. One of them contains locations with certain spots.

data_locs <- data.frame(
  Year = c(2000, 2001, 1993, 1993, 1994, 1995),
  Month = c(1, 1, 2, 9, 9, 9),
  Day = c(24, 22, 4, 9, 21, 27),
  Long = c(11.3667, 11.6167, -0.2833, -8.9848, -8.9833, -9.3048),
  Lat = c(57.6833, 57.5500, 60.0000, 42.2412, 42.2428, 41.9963),
  Depth = c(68, 29, 141, 99, 99, 170)
)

And on the other side I have a .nc file with data from Copernicus with some variables: temperature, salinity, ocean mix layer thickness. ( (https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description )

What I want to do is extract the values of the raster matching the date (year/month/day), location and depth the get the projected values of the variables. However, all examples I can find online are using ncvar_get to get grided values for latitude, longitude, etc. and then looking for closes locations instead of using the capabilities of the rasters.

It may be a problem of concept but isn't it better to use the projected? How do I extract the values of the locations in data_locs?