I could be mistaken, but I always thought that for jpegs the spatial info is stored in a .jpegw file and since ST_ASJPEG only outputs the jpg part it wouldn't keep the spatial ref info.
Are you saying you loose it at the ST_ColorMap part or the ST_AsJPEG. I would expect it maintained in ST_ColorMap and lost at ST_AsJPEG call.
From: postgis-devel [mailto:[hidden email]] On Behalf Of David Haynes II Sent: Friday, April 22, 2016 12:51 PM To: PostGIS Development Discussion <[hidden email]> Subject: [postgis-devel] ST_Colormap
Working on an application for clipping rasters (data.terrapop.org/terraclip) and running into an issue with the ST_Colormap function. It seems that whenever we run the ST_Colormap function we lose the spatial reference information for the image.This is the sample of the query that we are running. The query is successful, but the resulting images can be built into a vrt with gdal. I'm using PostgreSQL 9.3.7 and POSTGIS 2.1.7.
WITH projection as
SELECT ST_SRID(rast) as srid
SELECT sgl.id as sample_geog_level_id, gi.id as geog_instance_id, gi.label as geog_instance_label,
gi.code as geog_instance_code, ST_Transform(bound.geog::geometry, prj.srid) as geom
FROM projection prj, sample_geog_levels sgl
inner join geog_instances gi on sgl.id = gi.sample_geog_level_id
inner join boundaries bound on bound.geog_instance_id = gi.id