Returns metadata from a raster object or a specific band as a JSON string.
The three overloads follow a progressive pattern:
No `key`: returns all metadata items as a JSON object.
With `key`: returns the value for a single metadata item; pass
'all'to get all items as a JSON object.With `band` and `key`: same as above, but scoped to the metadata of a specific band.
Syntax
text ST_MetaData(raster raster_obj);
text ST_MetaData(raster raster_obj,
text key);
text ST_MetaData(raster raster_obj,
integer band,
text key);Parameters
| Parameter | Type | Description |
|---|---|---|
raster_obj | raster | The raster object. |
band | integer | The band number, starting from 0. |
key | text | The name of the metadata item to retrieve. Pass 'all' to return all metadata items as a JSON object. |
Return value
All three overloads return text.
| Call pattern | Return value |
|---|---|
No key argument | All metadata items as a JSON object |
key set to a specific name | The value of that metadata item |
key set to 'all' | All metadata items as a JSON object |
band + key set to a specific name | The value of that metadata item in the specified band |
band + key set to 'all' | All metadata items of the specified band as a JSON object |
Examples
Get all object-level metadata
SELECT ST_MetaData(raster_obj) FROM raster_table;Get a specific metadata item by name
SELECT ST_MetaData(raster_obj, 'swh#scale_factor')
FROM raster_table;Output:
st_metadata
-----------------------
0.0001488117874873806Get all object-level metadata using key='all'
SELECT ST_MetaData(raster_obj, 'all')
FROM raster_table;Output:
st_metadata
-----------------------
{"AREA_OR_POINT":"Area"}Get a specific metadata item from a band
SELECT ST_MetaData(raster_obj, 0, 'NETCDF_DIM_time')
FROM raster_table;Output:
st_metadata
-------------
1043112Get all metadata for a band using key='all'
SELECT ST_MetaData(raster_obj, 0, 'all')
FROM raster_table;Output:
{"add_offset":"4.907141431495487","long_name":"Significant height of combined wind waves and swell","missing_value":"-32767","NETCDF_DIM_time":"1043112","NETCDF_VARNAME":"swh","scale_factor":"0.0001488117874873806","units":"m","_FillValue":"-32767"}