Looking at a NetCDF file that contains a subdatasets for the variables temp
, lat
, lng
and a couple others
Temperature (4 dimensions)
- depth (20)
- time (240 time steps)
- x (38 pixels)
- y (53 pixels)
Lat (2 dimensions)
- x (38 pixels)
- y (53 pixels)
(the value is the Lat - i.e. the y - coordinate)
Lng (2 dimensions)
- x (38 pixels)
- y (53 pixels)
(the value is the Lng - i.e. the x - coordinate)
After processing NetCDF variables into PostGIS via raster2pgsql
, I find WRT to these variables:
- Temperature: 4800 bands (i.e a 2D grid per depth per time step)
- Lng: 1 band (i.e. a 2D grid)
- Lng: 1 band (i.e. a 2D grid)
============
I would like to run the ST_Contour
function on the temperature raster (band 1), but I somehow need to associate the grid position of the values with a value from the coordinate dimension.
In other words I need to 'join' values in the temperature (band 1) raster to values in the Lat and Long rasters.
What are the best ways of doing this? (The lat/lng values are unique per pixel in the band 1 temperature raster)
My current idea is to:
- Use
ST_PixelAsCentroids
to generate X/Y coordinates per value as rows - Join Lat/lng columns using X/Y values
- Group values into 'buckets' - with each row in the output table now representing a list of coordinates that make up a polygon
But if there is a way to use ST_Contour
directly I think that would be better (I can't see it)