The code I am using for clip feature is :
raster ST_Clip(raster rast, geometry geom, double precision nodataval=NULL, boolean crop=true);
I tried clip a shape depends on the polygon from the Raster Data. But the PostGIS would clip the raster depend on the Bounding Box of the polygon, and put the Non-data value as 0. Even I tried to modify that with code:
SELECT ST_Clip(rast,geometry, ARRAY[-9999],true) FROM dtm, polygons WHERE polygons.polygonid = 1;
After I dump the data as a ASC-II file from the PostGIS, using gdal_translate with another option -a_nodata -9999, I find out it only changes the Header of the ASC-II file not the exact bounding box value.
Is there anyway to change the value from 0 to -9999, or someway to clip the raster depending on the polygon rather than the Bounding Box of the polygon.